In plain javascript, I can remove the first element of an array and store it in a variable like:
var rows = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var firstRow = rows.shift();
// now firstRow contains the first element of the original rows array,
// and rows contains the remaining elements.
How do I do the same thing with a jQuery collection?
var $rows = $('#some-table').find('> tbody > tr');
// ?
// ?
var rows = $('tr');
var first = rows.first();
var rest = rows.slice(1);
Reference:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With