---
title: "谷歌浏览器JS断点调试简介"
author: "QuarterLifeForJava"
date: "2014-10-29T12:35:38Z"
tags: []
categories: ["Web前端"]
slug: "js"
draft: false
lastmod: "2014-10-29T12:39:29Z"
id: 2149198
url: "https://quarterlifeforjava.iteye.com/blog/2149198"
---

先写个简单的代码：

```js

<html>
<head>
<script>
function test(){
	var x=10,y=0,z=0;
	for(var i=0;i<x;i++){
		y+=i;
	}
	z = z + y - x;
	document.getElementById("a").value = z;
};
</script>
<head>
<body>
<input type='text' id='a'/><button onclick='test()'>click me</button>
</body>
</html>

```

1、打开谷歌浏览器，然后按F12
2、点击Sources，在某一行上设置断点，如第五行
![](http://dl2.iteye.com/upload/attachment/0102/5959/e1122919-4259-3399-a6c6-bd7b353ea0d1.bmp)
3、单击“click me”触发事件，进入调试
4、按F10单步执行
![](http://dl2.iteye.com/upload/attachment/0102/5961/f8ee4e20-0f55-33c7-888d-fe4f79df4d0b.bmp)