一 html代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JS断点调试法</title> <!--外部js--> <script src="resource/js/jsdemo1.js"></script> </head> <body> <h1>代码调试</h1> <!--JS代码也能够写在这里--> </body> </html>
二 JS代码
var socre = 80; if (socre > 60 && socre < 70) { console.log("通常"); } else if (socre >= 70 && socre < 80) { console.log("良好"); } else { console.log("其余"); }
三 调试方法截图
1 谷歌浏览器,单击F12,进入开发者模式。javascript
2 进入Sources页签,找到要调试的js代码。html
3 打断点java
4 单步执行浏览器