[英]Checkbox state if not checked
到目前為止,我有以下代碼,但是我遇到了一個問題,那就是如果未將data-id
設置為checked
那么如何創建“狀態”?
碼:
$("input[type='checkbox']").each(function(){
if ($(this).is(":checked")) checkbox.push($(this).data("id"))
})
我在想這樣的事情:
$("input[type='checkbox']").each(function(){
if ($(this).is(":checked")) checkbox.push($(this).data("id"))
{
$state = 1;
}else{
$state = 0;
}
})
代碼可能像這樣:
$("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.