jQuery: Test if checkbox is NOT checked

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

    try this one

    if ($("#checkSurfaceEnvironment-1:checked").length>0) {
        //your code in case of NOT checked
    }
    

    In Above code selecting the element by Id (#checkSurfaceEnvironment-1) then filter out it's checked state by (:checked) filter.

    It will return array of checked element object. If there any object exists in the array then if condition will be satisfied.

提交回复
热议问题