Selecting empty rows in a table using jQuery

I am using jQuery along with the jQuery validation plugin.

I have a table in which each column after the first column contains a form field, such as a checkbox, text field, etc. I use <th>for headings, so only elements <tr>have form fields.

How to select all rows, all fields of which are filled? I am talking empty about a text field with the value undefined, a flag is checked, a selection field without anything, etc. I should not select a line if it has at least one non-empty field form.

Is it possible? Can someone shed some light on this?

+3
source share
1 answer

This should not be too complicated using .filter():

$('tr').filter(function(){
    return !$(this).find('input:text:not(:empty), textarea:not(:empty), input:checked, option:selected').length;
});

tr,

  • /

false, (.. ).

+4

Source: https://habr.com/ru/post/1789557/


All Articles