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
时间: 2024-10-12 07:57:31