Check if at least one checkbox is checked using jQuery

前端 未结 9 1163
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-31 11:31

I have five checkboxes. Using jQuery, how do I check if at least one of them is checked?



<
9条回答
  •  傲寒
    傲寒 (楼主)
    2020-12-31 12:16

    This should do the trick:

    function isOneChecked() {
        return ($('[name="service[]"]:checked').length > 0);
    }
    

提交回复
热议问题