click event for option doesn't work in IE

前端 未结 7 2011
一整个雨季
一整个雨季 2020-12-16 21:11

I have a multiple select tag, and I need to write the function onclick of it\'s options, because I need to get the value of last clicked option, but when I wrote the followi

7条回答
  •  爱一瞬间的悲伤
    2020-12-16 21:58

    don't bind it on option

    $("#multiple_select").click(function(){
         alert("works");
    });
    

    accepted answer:

    $(document).ready(function()
    {
        var options = $("#supply_cities_select :selected");
        var lastOption;
        $("#supply_cities_select").click(function()
            {
                lastOption = $(this).find(':selected').not(options);
                options = $(this).find(':selected');
            })
    });
    

提交回复
热议问题