Click event on select option element in chrome

前端 未结 13 977
闹比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:17

    Looking for this on 2018. Click event on option tag, inside a select tag, is not fired on Chrome.

    Use change event, and capture the selected option:

    $(document).delegate("select", "change", function() {
        //capture the option
        var $target = $("option:selected",$(this));
    });
    

    Be aware that $target may be a collection of objects if the select tag is multiple.

提交回复
热议问题