[英]Checkbox state if not checked
I so far have the following code but I am having an issue and thats how can create the "state" if the data-id
has not been set as checked
? 到目前为止,我有以下代码,但是我遇到了一个问题,那就是如果未将
data-id
设置为checked
那么如何创建“状态”?
Code: 码:
$("input[type='checkbox']").each(function(){
if ($(this).is(":checked")) checkbox.push($(this).data("id"))
})
I was thinking something like this: 我在想这样的事情:
$("input[type='checkbox']").each(function(){
if ($(this).is(":checked")) checkbox.push($(this).data("id"))
{
$state = 1;
}else{
$state = 0;
}
})
The code might be like: 代码可能像这样:
$("input[type='checkbox']").each(function(){
if ($(this).is(":checked"))
{
checkbox.push($(this).data("id"));
$state = 1;
}else{
$state = 0;
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.