下拉列表的Jquery背景

时间:2012-08-13 18:00:06

标签: jquery asp.net

我有一个下拉列表,我想让列表中的特定项目背景颜色为黄色,我不确定jquery代码。

这是脚本:

<script language="text/Javascript">
    $(function(){
        $('select[id="ddlParticipants"]'.rows[2].bgColor = "#FFFF00")
    })
</script>

以及下面的下拉列表:

<asp:DropDownList ID="ddlParticipants" runat="server" Width="300px"
     AutoPostBack="True" 
     onselectedindexchanged="ddlParticipants_SelectedIndexChanged" 
     meta:resourcekey="ddlParticipantsResource1">
     <asp:ListItem Text="<%$ Resources:Resources, Select %>" 
         meta:resourcekey="ListItemResource1"></asp:ListItem>
     <asp:ListItem Text="---I am a NEW participant---" Value="0" 
         meta:resourcekey="ListItemResource2"></asp:ListItem>
</asp:DropDownList>

我想制作一个读取&#34;我是新参与者的列表项目&#34;黄色。 有人有什么想法吗?

由于

1 个答案:

答案 0 :(得分:1)

使用标记无法实现您的目标。 <asp:dropdownlist>在HTML中呈现为<select ..>元素,您无法在<options>元素内设置<select>样式。您将不得不使用li或类似的东西来诉诸其他技巧。