我有一些行的下表,并希望禁用每行内的所有控件。
下面是我的 HTML 代码:
<table id="tblChildData">
<tr id="trChild2">
<td>
2
</td>
<td style="height: 30px;">
<%:Html.TextBoxFor(m=>m.childName2) %><%--<br />
<%: Html.ValidationMessageFor(m=>m.SpouseName,null,new{@Class="field-validation-message"}) %>--%>
</td>
<td style="height: 30px; text-align: center;">
M<%: Html.RadioButtonFor(m=>m.genderIdChild2,1) %>
F<%:Html.RadioButtonFor(m=>m.genderIdChild2,2) %>
</td>
<td style="height: 30px; text-align: center;">
<%:Html.TextBoxFor(m=>m.ageChild2,new{Style="width:30px;",maxlength=3}) %><%--<br />
<%:Html.ValidationMessageFor(m=>m.SpouseAge,null,new{@Class="field-validation-message"}) %>--%>
</td>
<td style="height: 30px; text-align: center;">
Married<%: Html.RadioButtonFor(m=>m.maritialStatusChild2,1) %>
UnMarried<%:Html.RadioButtonFor(m=>m.maritialStatusChild2,2) %>
</td>
</tr>
</table>
下面是我用来禁用每个表行内的控件的 jQuery 代码:
$("#trChild2").find("input,button,textarea").attr("disabled", true);
$("#trChild2").hide();
$("#trChild3").find("input,button,textarea").attr("disabled", true);
$("#trChild3").hide();
$("#trChild4").find("input,button,textarea").attr("disabled", true);
$("#trChild4").hide();
$("#trChild5").find("input,button,textarea").attr("disabled", true);
$("#trChild5").hide();
$("#trChild6").find("input,button,textarea").attr("disabled", true);
$("#trChild6").hide();
$("#trChild7").find("input,button,textarea").attr("disabled", true);
$("#trChild7").hide();
$("#trChild8").find("input,button,textarea").attr("disabled", true);
$("#trChild8").hide();
$("#trChild9").find("input,button,textarea").attr("disabled", true);
$("#trChild9").hide();
$("#trChild10").find("input,button,textarea").attr("disabled", true);
$("#trChild10").hide();
$("#trChild11").find("input,button,textarea").attr("disabled", true);
$("#trChild11").hide();
$("#trChild12").find("input,button,textarea").attr("disabled", true);
$("#trChild12").hide();
但我不知道为什么它只隐藏表格行而不禁用行内的控件......
我也在 jsfiddle 上试过这个,但它似乎工作正常:http: //jsfiddle.net/3QuT4/1/
请帮我..
谢谢,
阿曼