一 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 單步執行瀏覽器