开发者

IE 8 option selected attribute not rendered in AJAX requests

When I load html content using AJAX that includes a selected option, it is not rendered on the client.

For example

<option selected='selected'>text</option>

Now if I use

$("option [selected]")

I get empty result, but it works well in FireFox. I che开发者_运维百科cked source code using Develper Tools and selected is not in the html content. That's weird!


I'm having the same problem, and I think this is an IE8 issue, as it seems to work in IE7...

Have run some tests and I suggest that you try a conditional statement in jQuery and use the square brackets with anything else but IE, and for IE use the colon version:

non IE: $("option[selected]");

IE: $("option:selected");

PS. to be more clear, you can use the colon version for everything but FireFox 3, so FF4 and WebKit will also work with the colon version. Haven't done a multi version thorough test, just assume latest as of this date. So I guess it's up to you if you want to do a conditional based on IE or FF 3...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜