After clicking the parent element as long as the div sub-element specific response (jQuery example)

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/baidu_40537062/article/details/101625697

For example 1

$(".applyDialog").on("click",function(e){
    if(e.target.className=="aaMIRight choosed"){
    //执行代码
        $(".applyDialog").removeClass("choosed");
    }else{  
        return;
    }
});

Example 2

$(".applyDialog").on("click",function(e){
    if(e.target.classList[0]=="applyDialog"){
        $(".applyDialog").removeClass("choosed");
    }else{  
        return;
    }
});

Guess you like

Origin blog.csdn.net/baidu_40537062/article/details/101625697