一个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");                }            })
         
        }
   )我这样写怎么不得啊?

解决方案 »

  1.   

     $(document).ready(function () {
                $("#Checkbox1").click(function () {
                    if (this.checked==true) {
                        $("#text1").removeAttr("disabled");
                    }
                    if (this.checked == false) {
                        $("#text1").attr("disabled", "disabled");
                    }
                });
            }
       );
      

  2.   

    其实你的代码只有一点点问题, 
    $("#text1").attr("disabled", "true");
    改成:
    $("#text1").attr("disabled",true);
    去掉双引号就好了