簡體   English   中英

復選框狀態(如果未選中)

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM