Click event on select option element in chrome

前端 未结 13 1126
闹比i
闹比i 2020-11-22 11:38

I\'m having a problem in Chrome with the following:

var items = $(\"option\", obj);  

items.each(function(){

    $(this).click(function(){

           


        
13条回答
  •  时光取名叫无心
    2020-11-22 12:01

    Maybe one of the new jquery versions supports the click event on options. It worked for me:

    $(document).on("click","select option",function() {
      console.log("nice to meet you, console ;-)");
    });
    

    UPDATE: A possible usecase could be the following: A user sends a html form and the values are inserted into a database. However one or more values are set by default and you flag this automated entries. You also show the user that his entry is generated automatically, but if he confirm the entry by clicking on the already selected option you change the flag in the database. A rare sue case, but possible...

提交回复
热议问题