鼠标从子元素拖动到父元素上阻止事件冒泡
作者:
coderfl | 来源:发表于
2021-11-12 16:50 被阅读0次<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.d2{width: 100px;height: 100px;background: peru;position: absolute;z-index: 2}
</style>
</head>
<body>
<div class="d2"></div>
</body>
<script>
window.onmousedown=function(){
console.log(111);
}
const d2 = document.querySelector('.d2')
d2.onmousedown = function(e){
e.stopPropagation()
}
</script>
</html>
本文标题:鼠标从子元素拖动到父元素上阻止事件冒泡
本文链接:https://www.haomeiwen.com/subject/gujozltx.html
网友评论