Native js event proxy method

Source: Internet
Author: User

[Html] view plaincopy <div id = "gaga"> <a href = "#" gaga = "xixi"> 1 </a> <a href = "#"> 10 </a> <a href = "#"> 100 </a> <a href = "#"> 1000 </a> <a href = "#"> 10000 </a> <a href = "#"> 100000 </a> <a href = "#"> 1000000 </a> <a href = "#"> 10000000 </ <a href = "#"> 100000000 </a> <a href = "#"> 1000000000 </a> <a href = "#"> 10000000000 </> <a href = "#"> 100000000000 </a> </div> <script> var gaga = document. getElementById ("gaga"); gaga. o Nclick = function (e) {var e = e | window. event; var Target = e. srcElement | e.tar get; // srcElement this only supports firefox alert (Target. tagName); if (Target. tagName. toUpperCase () = "A") {alert (Target. innerHTML) ;}; return false; // prevent redirection}; </script> This feature eliminates the need to bind an onclick event to each a link, reducing memory leakage, improves performance and reduces the risk of browser crashes. But not all events can bubble up. Blur, focus, load, and unload cannot bubble like other events. In fact, blur and focus can be obtained by event capture rather than event bubbling (in browsers other than IE ). Note some points when managing mouse events. If your code processes the mousemove event, you may encounter a high performance bottleneck, because the mousemove event is triggered very frequently. Mouseout is difficult to manage by event proxy because of its weird performance.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.