0
<!DOCTYPE HTML>
<html>
<body>
<style type="text/css">
#a {background-color:blue;width:100px;height:200px;}
#b {background-color:red;margin-left:25px;width:50px;height:100px;}
</style>
<div id="a">a
<div id="b">b</div>
</div>
<script>
document.getElementById("a").onclick = function() {console.log("A is clicked");}
document.getElementById("b").onclick = function() {console.log("B is clicked");}
document.onclick = function() {console.log("Document is clicked");}
</script>
</body>
</html>
對於上面的代碼,它註冊3單擊事件處理程序,他們也反對吧?如果是這樣,我如何檢查這3個處理程序/對象的屬性,控制檯中的方法?
究竟是什麼你試圖做/找出?在這種情況下事件處理程序只是功能。它們具有與其他功能相同的屬性。 –