<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>点击事件</title>
</head>
<body>
<div id="dan" style="width:300px;height:300px;border:2px solid gray;">点我试试</div>
<div class="shuang" style="width:300px;height:300px;border:2px solid gray;">点我两下试试</div>
</body>
<script>
//找到对象
var dan = document.getElementById('dan');
//添加事件
//onclick别再写错了 写错了耽误好久= =|||
dan.onclick = function(){
//修改属性
this.style.background = 'gray';
};
//找到对象
var shuang = document.getElementsByClassName('shuang');
//添加事件
shuang[0].ondblclick = function(){
this.style.background = 'pink';
};
</script>
</html>