标签内容
<div class="box">
???????请编写javascript代码,完成如下功能要求:<br />
???????1.取消复选款后,要求促销价格、促销开始结束日期3个控件不可用。<br />
???????2.选中复选框后,要求促销价格、促销开始结束日期3个控件可用。
???</div>
???<div class="box">
???
???????<table id="table1" class="mytable">
???????????<tr>
???????????????<td>是否促销:</td>
???????????????<td><input type="checkbox" id="chkPromote" /></td>
???????????</tr>
???????????<tr>
???????????????<td>
???????????????????促销价格:
???????????????</td>
???????????????<td>
???????????????????<input type="text" id="txtPromotePrice" />
???????????????</td>
???????????</tr>
???????????<tr>
???????????????<td>
???????????????????促销日期:
???????????????</td>
???????????????<td>
???????????????????<input type="text" id="txtStart" />-
???????????????????<input type="text" id="txtEnd" />
???????????????</td>
???????????</tr>
???????</table>
???</div>
Jquery内容
<script>
$(function () {
???????????$("input[type=text]").attr("disabled", true).val("不可使用");
???????????$("input[type=checkbox]").click(function () {
??????????????
???????????????var $cr = $("input[type=checkbox]");
???????????????if ($cr.is(":checked")) {
???????????????????
???????????????????$("input[type=text]").attr("disabled", false).val("可以使用");
???????????????}
???????????????else {
???????????????????
???????????????????$("input[type=text]").attr("disabled", true).val("不可使用");
???????????????}
???????????});
??????????
???????});
???</script>
Jquery中复选框选中取消实现文本框的显示隐藏
原文地址:https://www.cnblogs.com/yunnanyanjin/p/9481978.html