开发者

How to add styling to an option in ie 8 via JQuery

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
    {
        $('开发者_Go百科#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!


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'}).


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:

  • Is it possible to style a select box?
  • Styling HTML SELECT in Internet Explorer
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜