Home  >  Article  >  Web Front-end  >  How to debug JS code using the browser

How to debug JS code using the browser

清浅
清浅Original
2019-01-31 13:11:0213654browse

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.

How to debug JS code using the browser

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

How to debug JS code using the browser

Chrome Browser

1. Open Chrome Browser, directly select Chrome to run, the same operation as other browsers

How to debug JS code using the browser

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:

How to debug JS code using the browser

3. We select "Sources", as follows

How to debug JS code using the browser

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:

How to debug JS code using the browser

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:

How to debug JS code using the browser

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn