option & jQuery .click() won't work together
Posted
by meow
on Stack Overflow
See other posts from Stack Overflow
or by meow
Published on 2010-05-12T10:18:13Z
Indexed on
2010/05/12
10:24 UTC
Read the original article
Hit count: 256
Hello,
this works great in FF but not in IE, Chrome or Safari.
$('#countryDropDown option').click(function() {
var countryID = $(this).val();
dostuff();
});
// countryDropDown = id of select
So, as you can see I want to attach a click event to each option.
I alos tried
var allOpts = $('#countryDropDown option'),
l = allOpts.length,
i = 0;
for (i = 0; i < l; i += 1) {
$(allOpts[i]).click(function() {
var countryID = $(this).val();
doStuff();
});
}
It still does not want to work in any other browser but FF. What am I doing wrong? Thanks
© Stack Overflow or respective owner