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()更改更改事件之前。调用。更改()
而不是。单击()
没问题,很乐意帮助。没问题,很乐意帮助。没问题,很乐意帮助。没问题,很乐意帮助。没问题,很乐意帮助。