Take the 2-minute tour ×

Possible Duplicate:
What is the best way to remove a table row with jQuery?

If I have table with 3 rows using tr tag, how do I remove the first row (index 0) with either jquery or some other javascript?

share|improve this question
+1 for asking for a non-jQuery approach. –  gilly3 Apr 28 '11 at 16:40
add comment

marked as duplicate by Jeff Atwood Apr 30 '11 at 5:45


4 Answers

This would remove the 3rd row in a table.

$("table tr:eq(2)").remove();

Also, don't forget to use <thead> and <tbody> in your <table>. It makes things more accessible and helps if you want to use a plug-in for sorting later down the road.

share|improve this answer
add comment



However, like @Gregg said, take a look at official docs

share|improve this answer
add comment

The jQuery docs are a great resource for this kind of thing...

share|improve this answer
add comment

Here's the "some other javascript" approach, which is itself very simple:

share|improve this answer
Of interest: developer.mozilla.org/en/DOM/HTMLTableElement –  user1385191 Apr 28 '11 at 18:11
add comment
