I would expect this:
<asp:CheckBox ID="CheckBox1" runat="server" CssClass="myClass" />
<asp:RadioButton ID="RadioButton1" runat="server" CssClass="myClass" />
<asp:TextBox ID="TextBox1" runat="server" CssClass="myClass" />
...to render like this (with some attributes removed for simplicity):
<input id="CheckBox1" type="checkbox" class="myClass" />
<input id="RadioButton1" type="radio" class="myClass" />
<input id="TextBox1" type="text" class="myClass" />
...when in fact, the RadioButton
and CheckBox
get wrapped with a span
tag and the CSS class gets applied there.
<span class="myClass"><input id="CheckBox1" type="checkbox" /></span>
<span class="myClass"><input id="RadioButton1" type="radio" /></span>
<input type="text" id="TextBox1" class="myClass" />
Is there a reason for this and is there a way to avoid it? It makes jQuery selectors ugly since you can't catch all of them with:
$("input.myClass")
Granted it is just going to:
$("input.myClass, span.myClass input")
...but that is ugly. I could write my own selector, but again not as elegant as it should be.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…