views:

20

answers:

2

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
  }
}
A: 

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.

sassinak
+1  A: 

try this:

$("select").each(function(){

    $(this).children("option:selected").each(function(){

       //handle this $(this).val()

    });                 
});

works fine for me =]

madeinstefano