一个Checkbox,一个text
当Checkbox被选择的时候,text的disabled为false
当Checkbox被未被选择的时候,text的disabled为true
$(document).ready(function () { $("#Checkbox1").click(function () {
if (this.checked==true) {
$("#text1").attr("disabled", "false"); } if (this.checked == false) {
$("#text1").attr("disabled", "true"); } })
}
)我这样写怎么不得啊?
当Checkbox被选择的时候,text的disabled为false
当Checkbox被未被选择的时候,text的disabled为true
$(document).ready(function () { $("#Checkbox1").click(function () {
if (this.checked==true) {
$("#text1").attr("disabled", "false"); } if (this.checked == false) {
$("#text1").attr("disabled", "true"); } })
}
)我这样写怎么不得啊?
$("#Checkbox1").click(function () {
if (this.checked==true) {
$("#text1").removeAttr("disabled");
}
if (this.checked == false) {
$("#text1").attr("disabled", "disabled");
}
});
}
);
$("#text1").attr("disabled", "true");
改成:
$("#text1").attr("disabled",true);
去掉双引号就好了