Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery启动复选框检查未按预期工作_Jquery_Events_Checkbox - Fatal编程技术网

jquery启动复选框检查未按预期工作

jquery启动复选框检查未按预期工作,jquery,events,checkbox,Jquery,Events,Checkbox,我有这个密码: $(document).ready(function() { $("input[type='checkbox']").click(); $("input[type='checkbox']").change(function(e) { if ( $("input[type='checkbox']").is(":checked") === true ) { $("

我有这个密码:

$(document).ready(function() {

        $("input[type='checkbox']").click();

        $("input[type='checkbox']").change(function(e) { 

            if ( $("input[type='checkbox']").is(":checked") === true ) 
            {
                $("textarea").val("");
                $("textarea").prop("placeholder", "");  
                $("textarea").prop("disabled", true);
            }
            else
            {
                $("textarea").prop("disabled", false);
                $("textarea").prop("placeholder", "Write here"); 
            }

        }); //checkbox .change()

    });
加载页面时,会发生单击事件,但不会启动更改事件

对吗?还是我做错了什么

谢谢。

尝试更改:

 if ( $("input[type='checkbox']").is(":checked") === true )

尝试更改:

 if ( $("input[type='checkbox']").is(":checked") === true )

尝试更改:

 if ( $("input[type='checkbox']").is(":checked") === true )

尝试更改:

 if ( $("input[type='checkbox']").is(":checked") === true )


单击复选框后,您将设置事件。你也应该在活动中使用“this”:

$(document).ready(function() {



    $("input[type='checkbox']").change(function(e) { 

        if ( $(this).is(":checked") === true ) 
        {
            $("textarea").val("");
            $("textarea").prop("placeholder", "");  
            $("textarea").prop("disabled", true);
        }
        else
        {
            $("textarea").prop("disabled", false);
            $("textarea").prop("placeholder", "Write here"); 
        }

    }); //checkbox .change()

    $("input[type='checkbox']").click();
});

单击复选框后,您将设置事件。你也应该在活动中使用“this”:

$(document).ready(function() {



    $("input[type='checkbox']").change(function(e) { 

        if ( $(this).is(":checked") === true ) 
        {
            $("textarea").val("");
            $("textarea").prop("placeholder", "");  
            $("textarea").prop("disabled", true);
        }
        else
        {
            $("textarea").prop("disabled", false);
            $("textarea").prop("placeholder", "Write here"); 
        }

    }); //checkbox .change()

    $("input[type='checkbox']").click();
});

单击复选框后,您将设置事件。你也应该在活动中使用“this”:

$(document).ready(function() {



    $("input[type='checkbox']").change(function(e) { 

        if ( $(this).is(":checked") === true ) 
        {
            $("textarea").val("");
            $("textarea").prop("placeholder", "");  
            $("textarea").prop("disabled", true);
        }
        else
        {
            $("textarea").prop("disabled", false);
            $("textarea").prop("placeholder", "Write here"); 
        }

    }); //checkbox .change()

    $("input[type='checkbox']").click();
});

单击复选框后,您将设置事件。你也应该在活动中使用“this”:

$(document).ready(function() {



    $("input[type='checkbox']").change(function(e) { 

        if ( $(this).is(":checked") === true ) 
        {
            $("textarea").val("");
            $("textarea").prop("placeholder", "");  
            $("textarea").prop("disabled", true);
        }
        else
        {
            $("textarea").prop("disabled", false);
            $("textarea").prop("placeholder", "Write here"); 
        }

    }); //checkbox .change()

    $("input[type='checkbox']").click();
});

单击时,您尚未附加事件。编写
$(“输入[type='checkbox'])。单击()。请尝试与相同的代码

$(document).ready(function() {        

    $("input[type='checkbox']").change(function(e) { 
        alert("Yes event triggered now");
        if ( $(this).is(":checked") === true ) 
        {
            $("textarea").val("");
            $("textarea").prop("placeholder", "");  
            $("textarea").prop("disabled", true);
        }
        else
        {
            $("textarea").prop("disabled", false);
            $("textarea").prop("placeholder", "Write here"); 
        }

    }); //checkbox .change()

$("input[type='checkbox']").click();
});

单击时,您尚未附加事件。编写
$(“输入[type='checkbox'])。单击()。请尝试与相同的代码

$(document).ready(function() {        

    $("input[type='checkbox']").change(function(e) { 
        alert("Yes event triggered now");
        if ( $(this).is(":checked") === true ) 
        {
            $("textarea").val("");
            $("textarea").prop("placeholder", "");  
            $("textarea").prop("disabled", true);
        }
        else
        {
            $("textarea").prop("disabled", false);
            $("textarea").prop("placeholder", "Write here"); 
        }

    }); //checkbox .change()

$("input[type='checkbox']").click();
});

单击时,您尚未附加事件。编写
$(“输入[type='checkbox'])。单击()。请尝试与相同的代码

$(document).ready(function() {        

    $("input[type='checkbox']").change(function(e) { 
        alert("Yes event triggered now");
        if ( $(this).is(":checked") === true ) 
        {
            $("textarea").val("");
            $("textarea").prop("placeholder", "");  
            $("textarea").prop("disabled", true);
        }
        else
        {
            $("textarea").prop("disabled", false);
            $("textarea").prop("placeholder", "Write here"); 
        }

    }); //checkbox .change()

$("input[type='checkbox']").click();
});

单击时,您尚未附加事件。编写
$(“输入[type='checkbox'])。单击()。请尝试与相同的代码

$(document).ready(function() {        

    $("input[type='checkbox']").change(function(e) { 
        alert("Yes event triggered now");
        if ( $(this).is(":checked") === true ) 
        {
            $("textarea").val("");
            $("textarea").prop("placeholder", "");  
            $("textarea").prop("disabled", true);
        }
        else
        {
            $("textarea").prop("disabled", false);
            $("textarea").prop("placeholder", "Write here"); 
        }

    }); //checkbox .change()

$("input[type='checkbox']").click();
});

在更改更改事件之前调用click()。在更改事件之前调用click()。在更改事件之前调用click()。
.change()
您在更改事件之前调用click()。在更改事件之前调用click()。
.click()
您在调用click()。在更改事件之前调用click()。
.change()
。click()
您在调用click()更改更改事件之前。调用
。更改()
而不是
。单击()
没问题,很乐意帮助。没问题,很乐意帮助。没问题,很乐意帮助。没问题,很乐意帮助。没问题,很乐意帮助。