How to debug JS code in the browser: 1. Open the Chrome browser and directly select Chrome to run; 2. Enter the page and click the F12 or "Ctrl Shift I" shortcut key; 3. Select "Sources" , and set breakpoints for code debugging.
The operating environment of this article: Windows7 system, Dell G3 computer, javascript1.8.5&&Chrome76.0.
In the process of writing programs, we often encounter problems of one kind or another. At this time, we need to debug and see where the error occurs. But in JavaScript, if it always looks like this Debugging will be very inconvenient. At this time, the debugging tools that come with each browser come in handy
Chrome Browser
1. Open Chrome Browser, directly select Chrome to run, the same operation as other browsers
2. After entering the page, click F12 or Ctrl Shift I, you can also right-click the interface and select "examine". At this time, you will see the following interface:
3. We select "Sources", as follows
Click on the number in front, and a blue box will appear, which means it has been marked. This is code debugging in Chrome.
Firefox browser
Just follow the first step of Chrome.
Then after entering the page, click F12 or right-click the interface and select "View Elements". This interface will appear:
We can select the debugger, then find the file that needs to be debugged, and find the content that needs to be debugged in the debugging file, as follows:
Summary: The above is the entire content of this article. I hope it will be helpful for everyone to learn and debug JavaScript code
[Recommended course: JavaScript Tutorial]
The above is the detailed content of How to debug JS code using the browser. For more information, please follow other related articles on the PHP Chinese website!