1. 程式人生 > >js事件--事件流模型

js事件--事件流模型

1 var $input = document.getElementsByTagName("input")[0]; 2 var $div = document.getElementsByTagName("div")[0]; 3 var $body = document.getElementsByTagName("body")[0]; 4 5 $input.onclick = function(e){ 6 this.style.border = "5px solid red" 7 var e = e || window.e; 8 alert("red");
9 } 10 $div.onclick = function(e){ 11 this.style.border = "5px solid green"; 12 alert("green"); 13 } 14 $body.onclick = function(e){ 15 this.style.border = "5px solid yellow"; 16 alert("yellow"); 17 } 18 19 //依次彈出”red“,"green","yellow"