有什么办法来设置在一个单选按钮列表中的输入项的CSS类? 我想用类jQuery中引用这些表单值。
给定一个ASP.NET单选按钮列表上的listItems中设置类:
<asp:RadioButtonList ID="RadioButtonList" runat="server">
<asp:ListItem class="myClass" Text="Yes" Value="1" />
<asp:ListItem class="myClass" Text="No" Value="0" />
</asp:RadioButtonList>
将呈现为:
<span id="RadioButtonList" class="radioButtonListField myClass">
<span class="myClass">
<input id="RadioButtonList_0" type="radio" value="1"
name="RadioButtonList"/>
<label for="RadioButtonList_0">Yes</label>
</span>
<span class="myClass">
<input id="RadioButtonList_1" type="radio" value="0"
name="RadioButtonList"/>
<label for="RadioButtonList_1">No</label>
</span>
</span>
不幸的是,“myClass的”类被添加到<span>
包含该单选按钮项,而不是<input>
本身。 我怎么能得到它看起来像这个:
<span id="RadioButtonList" class="radioButtonListField myClass">
<span>
<input id="RadioButtonList_0" class="myClass" type="radio" value="1"
name="RadioButtonList"/>
<label for="RadioButtonList_0">Yes</label>
</span>
<span>
<input id="RadioButtonList_1" class="myClass" type="radio" value="0"
name="RadioButtonList"/>
<label for="RadioButtonList_1">No</label>
</span>
</span>
(这还不进入添加类来动态绑定RadioButtonLists的问题。)