JQuery detect dropdown value is selected even if it's not changed

前端 未结 7 1802
感动是毒
感动是毒 2021-01-05 01:29

Using JQuery or JavaScript, I want to detect when a user selects a value, even if they don\'t change the already selected value.

How can this be accomplished?

<
7条回答
  •  庸人自扰
    2021-01-05 02:12

    Have you tried something like:

    $('#MyID li').click(function(){ //my function });
    

    Here you are detecting clicks on the list elements inside your dropdown, which should be the different options. (If your HTML is slightly different, just inspect it and see what all the options have in common, what kind of elements are they?)

提交回复
热议问题