function test(){
alert("div1")
}
function test1(){
alert("div2")
}
console.log(document.getElementById("div1"))
console.info(document)
document.getElementById("div3").addEventListener("click",function(){
alert("div3")
})
//这里document不能用,如果要用,自己写一个html文件
<div id="div1" onClick="test()">
<div id="div2" onClick="test1()">
<div id="div3"></div>
</div>
</div>
#div1{
width:150px;
height:150px;
background:red;
}
#div2{
width:100px;
height:100px;
background:blue;
}
#div3{
width:50px;
height:50px;
background:white;
}