美文网首页
2018-08-16

2018-08-16

作者: YTF1214 | 来源:发表于2018-08-16 19:40 被阅读0次

<style>
*{
margin:0;
padding:0;
}

div1{

width:300px;
height:300px;
background: #f00;
line-height: 300px;

}

div2{

width:200px;
height:200px;
background: #f0f;
line-height: 200px;

}

div3{

width:100px;
height:100px;
background: #0ff;

}
</style>

<div id='div1'>
<div id='div2'>
<div id='div3'></div>
</div>
</div>

<script>
var div1=document.getElementById('div1');
var div2=document.getElementById('div2');
var div3=document.getElementById('div3');
div1.addEventListener('click',function(){
console.log('我是div1');
},true)
div2.addEventListener('click',function(){
console.log('我是div2');
},true)
div3.addEventListener('click',function(){
console.log('我是div3');
},true)
</script>

相关文章

网友评论

      本文标题:2018-08-16

      本文链接:https://www.haomeiwen.com/subject/wroobftx.html