jQuery: Test if checkbox is NOT checked

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

    I was looking for a more direct implementation like avijendr suggested.

    I had a little trouble with his/her syntax, but I got this to work:

    if ($('.user-forms input[id*="chkPrint"]:not(:checked)').length > 0)
    

    In my case, I had a table with a class user-forms, and I was checking if any of the checkboxes that had the string checkPrint in their id were unchecked.

提交回复
热议问题