如何在默认情况下禁用文本框并让用户通过复选框启用它?如何在默认情况下禁用文本框并在以后启用?
<input type="checkbox" id="sccb" name="science" value="science">
<script type="text/javascript">
$(document).ready(function(){
$('#sccb').click(function(){
if (this.checked) {
$('#cns').removeAttr("disabled");
}
else {
$("#cns").attr("disabled", true);
}
});
});
</script>
<input type="text" id="cns" name="coornamescience" disabled="disabled" size="30"></input>
随着一些JavaScript代码,但我没有看到任何[努力或独立研究的证据。(http://stackoverflow.com/questions/how-to-ask)的 – 2013-04-09 03:30:08
可能重复[启用/从下拉菜单中选择的选项禁用文本框](http://stackoverflow.com/questions/5258182/enable-disable-of-textbox-on-option-selected-from-drop-down-menu) – 2013-04-09 04:30:41