select option doesn't work in IE and SAFARI
the following code doesn't work in IE and Safari but works fine in firefox.
$('select#colors option').click开发者_StackOverflow(function() {
//this is for testing but I get no alert in IE and Safari
alert('item selected');
});
<select id="colors" class="select">
<option>Please select your style</option>
<option>Navy</option>
<option>Grey</option>
<option>Black</option>
</select>
any ideas!!
Try this one instead
$('select#colors').bind('change', function() {
alert('selected item changed');
});
You need to attach the function to the select rather than each option:
$('select#colors').click(function() {
alert('item selected: ' + $(this).val());
});
精彩评论