标签:style blog http color io java div sp cti
1 addEventListener("click", function() {}, useCapture:false);
<!DOCTYPE html> <html lang="en"> <head> </head> <body> <div id="content" class="c1"> <a id="b">hhaha</a> <a href="#!/fdaf">fda</a> <a href="#!/fdaaa">fdf</a> </div> <script> document.getElementById("b").addEventListener("click", function() { //this.href = this.href.replace("?", "#"); console.log("inner"); },true); window.addEventListener("hashchange", function() { console.log(location.hash); }, false); document.getElementById("content").addEventListener("click", function() { console.log("outer"); },true); </script> </body> </html>
-------------->outer
-------------->inner
默认是不用捕获的。---------->由内向外
------------->inner
------------->outer
区别于xmlhttp.send("GET", url, async:true);--------->表示是否异步async
JavaScript中事件捕获(Event capturing)-------------->由外向内,事件冒泡(Event bubblin)---------->由内向外
标签:style blog http color io java div sp cti
原文地址:http://www.cnblogs.com/daishuguang/p/3983329.html