onclick 阻止 冒泡 欄目 應用數學 简体版
原文   原文鏈接

 

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<div style='background:red;width:200px;height:50px' onclick='a()'>
    <input type='button' value='ok' onclick='b(event)'></input>
</div>
<script type="text/javascript">
     function a(e){
        console.log("div")
    }
    function b(e){
        console.log(e);
        if(e&&e.stopPropagation){
            e.stopPropagation();
        }else{
            window.event.cancelBubble =true;
        }
     }
</script>
</body>
</html>
相關文章
相關標籤/搜索
每日一句
    每一个你不满意的现在,都有一个你没有努力的曾经。
本站公眾號
   歡迎關注本站公眾號,獲取更多信息