I\'ve got a layout like this:
-
This is an old thread, but I'm curious* why nobody mentioned nth-child.
$("#parent > div:nth-child(n + " + index + ")").remove();
*Update: I didn't have enough rep to know it at the time, but there had been an nth-child
answer, deleted.
讨论(0)
-
To remove rows 0 and 1 select rows less than 2 using the lt selector and then remove them:
$('#parent div:lt(2)').remove();
讨论(0)
-
"Just remove (detach) all children of #parent
, starting at element N
":
$("#parent").children().slice(N).detach();
If the elements are not going to be reinserted, use remove()
instead of detach()
in order to discard data and events associated with the removed elements.
讨论(0)