Is there any way (in plain JS or jQuery) to detetect exactly that moment, a drop down (select-tag) opens? To clarify more, a small example:
If you click 5 times on a select, the following happens:
drop down opens > Event should fire
drop down closes
drop down opens > Event should fire
drop down closes
drop down opens > Event should fire
So far, I just can find events for the click/focus in/focus out.
Look at this code:
HTML:
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.2.min.js">
</script>
<select id="fire">
<option>One</option>
<option>Two</option>
</select>
<p></p>
JQuery:
var flag=1;
$("#fire").click(function(){
if(flag==1){
$("p").append("clicked ");
flag=0;
} else {
flag=1;
}
});
$("#fire").blur(function(){
flag=1;
});
jsFiddle is here
var select = document.getElementById('mySelect');
mySelect.addEventListener('mousedown', function() {
console.log('mousedown event fired on mySelect');
});
See this fiddle: http://jsfiddle.net/ToddT/hYT9q/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With