javascript - Jquery callback when any select box option is chosen (not changed) -
I have a dropdown selection form element when an option is selected, so I want to do something even If the value selected from the dropdown is already selected option, "On change" will not work in this case.
How can I do this?
Since your option is not "actually" changing, jQuery changes event will automatically fire Will not apply. Instead you have to pair it. Use the click event suggested by @ Peach: -
Sample code: -
// a local variable variable x = 0; $ ('# Single'). Click (function () {// Impression Local Variable 1 x = x + 1; // Since the click event will be removed twice (during the focus, selecting one more time and choosing another option) Compare the same selection For '2' (x == 2) {$ (this) .change (); x = 0;}}). To reset (work () {console.log (1); // to reset the value to 0 to the back of the X, set it as -1 (since the click event will be removed after the change). = -1;});
Comments
Post a Comment