jQuery see if any or no checkboxes are selected

前端 未结 8 1703
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 13:41

I know how to see if an individual checkbox is selected or not.

But Im having trouble with the following - given a form id I need to see if any of the check

8条回答
  •  半阙折子戏
    2020-12-02 14:34

    Without using 'length' you can do it like this:

    if ($('input[type=checkbox]').is(":checked")) {
          //any one is checked
    }
    else {
    //none is checked
    }
    

提交回复
热议问题