Click event on select option element in chrome

前端 未结 13 978
闹比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 11:57

    I know that this code snippet works for recognizing an option click (at least in Chrome and FF). Furthermore, it works if the element wasn't there on DOM load. I usually use this when I input sections of inputs into a single select element and I don't want the section title to be clicked.

    $(document).on('click', 'option[value="disableme"]', function(){
        $('option[value="disableme"]').prop("selected", false);
    });
    

提交回复
热议问题