如何通过 JQuery 将样式添加到 ie 8 中的选项
这就是我想要做的:
for (var i = 0; i < paramLength; i++) {
if (parameters[i].substr(0, 2) == '@_')//Required
{
$('#ddParam' + id).append($("<option style='font-style:italic'></option>").attr("value", parameters[i]).text(parameters[i] + ' (REQUIRED)'));
}
else
{
$('#ddParam' + id).append($("<option></option>").attr("value", parameters[i]).text(parameters[i]));
}
}
注意选项中的 STYLE 标签——这对我来说在 FF 中工作正常,但是(坚持住)——在 IE8 中不起作用,(不幸的是)这是我使用的浏览器正在设计这个应用程序......
任何建议和感谢!
Here is what I am trying to do:
for (var i = 0; i < paramLength; i++) {
if (parameters[i].substr(0, 2) == '@_')//Required
{
$('#ddParam' + id).append($("<option style='font-style:italic'></option>").attr("value", parameters[i]).text(parameters[i] + ' (REQUIRED)'));
}
else
{
$('#ddParam' + id).append($("<option></option>").attr("value", parameters[i]).text(parameters[i]));
}
}
NOTICE the STYLE tag in the OPTION -- this works fine for me in FF but (hang on to your hat) -- is not working in IE8 and that (unfortunately) is the browser that I am designing this app for....
Any suggestions and thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议使用类 - 它们比逐一添加单一样式更快。用于 jQuery 对象
addClass('classnameX')
或者如果您喜欢样式:css({'key1':'val1','key2':'val2'})
。I suggest using classes - they are faster than adding single styles one by one. Use on jQuery object
addClass('classnameX')
or if you like styles:css({'key1':'val1','key2':'val2'})
.您是否考虑过
在 IE8 之前,IE 不支持这一点,浏览器对该元素的样式有很大不同,就像它们对许多表单元素所做的那样。
更多问题:
Have you considered that styling capabilities of
<select>
elements is very browser specific.IE did not support that prior to IE8, browsers vary in style on that element a good deal as they do with many form elements.
Further Questions: