简体   繁体   中英

JQuery click event on select element click does not work in chrome on Linux (chrome on Windows works)

When I click on the select element in chrome, the event does not get triggered on first click (but after that, ie on second, third...). Why and how can I change that? (works in FF and in Chrome on Windows)

 $("select").click(function() { console.log("click"); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <select> <option>a</option> </select>

https://jsfiddle.net/pv2eajux/


Note: click on the text, not on the arrow

I have finally fixed it by replacing click with mouseup

 $("select").mouseup(function() { console.log("click"); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <select> <option>a</option> </select>

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