回顾js,
<html>
<body>
<div class="demo"style=" width=300px; heigth=300px; background-color=red;" >
<button>按钮</button>
</div>
//先设一个盒子,在盒子设置一个按钮

<script>
let demo = document.querySelector('.demo');
let btn = document.querySelector('button');
btn.addEventListener('click',function (e) { //事件冒泡是从里面到外面 1>2>3
// e.stopPropagation() //阻止事件冒泡
//e.preventDefault() //阻止默认事件
console.log(111111)
})
demo.addEventListener('click',function () {
console.log(22222)
})
//当点击按钮的时候,会逐次打印
</script>
1169

被折叠的 条评论
为什么被折叠?



