I've a dropdown (multiple select). I choose a few values, they are highlighted correctly, but jQuery doesn't recognize them as selected. this works in firefox and chrome, doesn't work in IE. this is the code
$("#myBox" +" option").each(function()
{
if ($(this).attr("selected") == true)
{
// do something
}
}
try this:
$("select").each(function(){
$(this).children("option:selected").each(function(){
//handle this $(this).val()
});
});
works fine for me =]
have you tried
$("#myBox option:selected").each(function(){
//do something
});
This is I usually handle select boxes and this seems to work well for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.