Example of event bubbling in JavaScript understanding

Source: Internet
Author: User

This #btncomfirmchoosecompany is a button on the bootstrap modal layer, but after clicking, the Click event is bootstrap the outer monitor hears, the effect is the modal popup layer is closed, so I do not want this click event is "passed" to the "outer" page.

Please note that the parameter E is missing from the beginning and the effect of the code does not meet my expectations.

$ ("#btnComfirmChooseCompany"). Click (function(e) {varCompanyName = ""; varCompanyID = ""; varhaschecked =false; varAllcheckbox = $ ("input[name= ' CompanyID ')");  for(vari = 0; i < allcheckbox.length; i++) {            if(allcheckbox[i].checked = =true) {haschecked=true; CompanyID= $ (Allcheckbox[i]). attr ("value")); CompanyName= $("#" +CompanyID). Parent (). Next (). text (); }        }        if(haschecked) {$ ("#txtKHName"). Val (CompanyName); $("#hidCompanyId"). Val (CompanyID); }        Else{alert ("Please choose a business!");            e. stoppropagation (); return false; }    });

The other equivalent notation

$ ("#btnComfirmChooseCompany"). Click (    comfirmchoosecompany);
function Comfirmchoosecompany (e) {    // Ibid., abbreviated }

Example of event bubbling in JavaScript understanding

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.