JQuery event to fire when a drop down is selected — but the value is not changed

后端 未结 5 621
名媛妹妹
名媛妹妹 2020-12-06 11:54

I have a dropdown menu that I want to connect a JQuery event to that fires if someone clicks on it but then selects the same option that is already selected.

I\'ve g

5条回答
  •  無奈伤痛
    2020-12-06 12:08

    use add class to solve this problem

     $("#test").change(function(event){
     if($(this).find('option:selected').hasClass('actived'))
       alert('already selected');//write you code here
     else
       $(this).find('option:selected').addClass('actived');
    
    });
    

    and refer this link http://jsfiddle.net/muthukumar0705/nARVu/1/

提交回复
热议问题