jquery select change event on the same option

后端 未结 2 585
执念已碎
执念已碎 2020-12-06 21:17

Here is my simple code:

$(\".test\").change(function(){
    alert(\"user clicked\");
});


                        
    
提交评论

  • 2020-12-06 22:15

    If you mean that there is only one thing in the select (like in the problem I was having), you could create a default disabled option, and set that as the selected. This would mean that if you had one option, onchange would fire because the disabled was the one that was previously selected:

    <option disabled selecte>Select an option</option>
    <option> Only Option </option>
    
    0 讨论(0)
  • 提交回复
    热议问题