Selecting a specific range of columns using jquery

I am looking to select columns 2-4 in the second row of the table. Does jquery have any "and" functions in its selectors? Or did I need to do something like this?

$('#id tr:eq(1)').find('td:lt(5)').find('td:gt(1)')
+3
source share
2 answers

I have not tried this, but theoretically it should work:

$('#id tr:eq(1) td:lt(5):gt(1)')
+3
source

. slice () works well

$('#tableId tr').eq(1).find('td').slice(1,4); //2nd row, 2nd-4th td

$('#tableId tr').slice(1,5); // get specific rows

$('#tableId td').slice(1,4) // get specific columns

$('#tableId tr').each(function() {
     // do code per row
     var $columnRange = $(this).find('td').splice(1,4);
});
+3
source

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


All Articles