“Any” boolean function in jquery

后端 未结 5 1215
再見小時候
再見小時候 2021-01-17 11:08

Is there any easy way to check if any elements in a jquery selector fulfill a condition? For instance, to check if any textboxes in a form are empty (kind o

5条回答
  •  旧巷少年郎
    2021-01-17 11:37

    jQuery has a lot of pseudo selectors built in: http://api.jquery.com/category/selectors/jquery-selector-extensions/

    You can also build your own with the filter() function: http://api.jquery.com/filter/

    $('input.tb').filter(function() { return this.value.length == 0});
    

提交回复
热议问题