开发者

Jquery and IE 7 - selected property not working for multiple select boxes, even when options are selected

I've a dropdown (开发者_如何学Cmultiple 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜