简体   繁体   中英

How do you prevent a ASP.NET drop down list from firing it's onclick event when on option is selected?

I have a ASP.NET drop down list which needs to execute some javascript when the user clicks the expand arrow to reveal the options list, but currently selecting an option also triggers the onclick event, which I do not want.

Is there any way to do this without using some sort of flag?

you need to prevent the bubbling from that nested element's click

thatElementOnclickFunction = function (evt) {
    evt = evt || window.event;
    evt.cancelBubble = true;
    if(evt.stopPropagation) evt.stopPropagation();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM