Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
157
rated 0 times [  162] [ 5]  / answers: 1 / hits: 20180  / 13 Years ago, wed, october 12, 2011, 12:00:00

Basically, I have drop down menu that looks like this:



<select>
<option>0</option>
<option selected=selected>1</option>
<option>2</option>
<option>3</option>
</select>


I am trying to write a function that is fired even when you select the same option, i.e. even if the drop-down is opened and re-select the selected option, I want it to execute the function.


More From » jquery

 Answers
13

If you mean selecting with the mouse, you can use mouseup. However, it will fire when the select box is being opened as well, so you'll need to keep track of the amount of times it was fired (even: select is being opened, odd: select is being closed): http://jsfiddle.net/T4yUm/2/.



$(select).mouseup(function() {
var open = $(this).data(isopen);

if(open) {
alert(1);
}

$(this).data(isopen, !open);
});

[#89657] Tuesday, October 11, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tyreek

Total Points: 421
Total Questions: 115
Total Answers: 102

Location: Marshall Islands
Member since Mon, May 31, 2021
3 Years ago
;