Firefox selectedIndex on select changes on hover
In Firefox, there seems to be some weird issues around when the selectedIndex
of a select
field changes. It seems to change on hover, rather than on click.
Using:
setInterval(function(){console.log($('select').prop('selectedIndex'));}, 1000);
I can see the selectedIndex
change as I hover over different items (the items getting a blue background and white text as I hover over them).
In Chrome, the selectedIndex
only changes when an option is clicked.
I can't think of a way to work around this - I've tried to capture clicks on the options and check those against a data attribute on the select as per this SO question but the click handler only seems to work sporadically.
So when i try this on my page:
$('select[name=sel1]').change(function(){
alert(this.value);
});
With this select:
<select name="sel1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
Than in firefox it only alerts when i select the option...
Greetings
链接地址: http://www.djcxy.com/p/49650.html