jQuery: Test if checkbox is NOT checked

前端 未结 18 970
太阳男子
太阳男子 2020-12-02 07:12

I\'m having trouble figuring this out. I have two checkboxes (in the future will have more):

  • checkSurfaceEnvironment-1
  • checkSurface
18条回答
  •  离开以前
    2020-12-02 08:12

    Here I have a snippet for this question.

    $(function(){
       $("#buttoncheck").click(function(){
            if($('[type="checkbox"]').is(":checked")){
                $('.checkboxStatus').html("Congratulations! "+$('[type="checkbox"]:checked').length+" checkbox checked");
            }else{
                $('.checkboxStatus').html("Sorry! Checkbox is not checked");
             }
             return false;
       })
        
    });
    
    



提交回复
热议问题