jQuery: Test if checkbox is NOT checked

前端 未结 18 988
太阳男子
太阳男子 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 07:48

    $("#chkFruits_0,#chkFruits_1,#chkFruits_2,#chkFruits_3,#chkFruits_4").change(function () {
            var item = $("#chkFruits_0,#chkFruits_1,#chkFruits_2,#chkFruits_3,#chkFruits_4");
        if (item.is(":checked")==true) {
            //execute your code here
        }
    
        else if (item.is(":not(:checked)"))
        {
            //execute your code here
        }
    
    });
    

提交回复
热议问题