Say I have a div containing an unlimited number of child divs. Is there an easy way to get jQuery to select the nth div and every div after it so I can change those (in this case, call remove() on old divs)?
You can use the ":gt()" selector:
// div's 10 and higher
$('div:gt(9)').show()
Typing this out of my head and the jQuery API doc (read: this is not tested), but the first thing I'd do is to
$('#container div').slice(-n).remove();
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