Jquery中復選框選中取消實現文本框的顯示隱藏


標簽內容

<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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM