JavaScript element code parsing

Source: Internet
Author: User

For some pages that do not know, If you can view how the js Code corresponding to the element works, you can turn to Chrome. The principle is that the debugger helps us parse the page element. We select the page element and use "review element" to quickly locate the Page code of the element, it also helps us track and parse the styles and js scripts corresponding to these page elements, so that we can understand the implementation of page structure and function, which makes it much easier for us to analyze the page source code.

Parse Element Method
Select the page element <span>... </span>, the Event Listeners in the menu bar on the right is the Event corresponding to this element. The debugger helps us find the reference method, even events corresponding to css styles can be parsed for US (a row of code was searched or tracked in the past, and it is indeed time-saving to locate them in one step ). We can see that there is a filter marked in the red box. We click to pull it down and select "Selected Node Only". This filters out the events corresponding to the Selected page element. The code is further transparent, which brings a lot of convenience and saves a lot of time.


Debugging
Similar to other scripting languages, there are two methods for debugging: one is breakpoint debugging, and the other is through the log printing method. The js built-in object console is called as follows:

If the variable data is an object, use the following method to print the log information:
Console. log (data );

Then, you can view debugging information in the debugger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.