jQuery: Test if checkbox is NOT checked

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

    There are two way you can check condition.

    if ($("#checkSurfaceEnvironment-1").is(":checked")) {
        // Put your code here if checkbox is checked
    }
    

    OR you can use this one also

    if($("#checkSurfaceEnvironment-1").prop('checked') == true){
        // Put your code here if checkbox is checked
    }
    

    I hope this is useful for you.

提交回复
热议问题