C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Jquery Delete All Table Rows Except First
WhatsApp
Soumalya Das
Aug 12
2016
2.1
k
0
2
HTML code
<
table
id
=
"tblGrid"
cellpadding
=
"10px"
cellspacing
=
"0"
border
=
"1"
>
<
tbody
>
<
tr
style
=
"background-color:black;color:white;font-size:18px;"
>
<
td
>
ID
</
td
>
<
td
>
Name
</
td
>
<
td
>
Location
</
td
>
<
td
>
Department
</
td
>
</
tr
>
</
tbody
>
<
tbody
>
<
tr
>
<
td
>
100
</
td
>
<
td
>
soumalya
</
td
>
<
td
>
kolkata
</
td
>
<
td
>
Accountant
</
td
>
</
tr
>
</
tbody
>
<
tbody
>
<
tr
>
<
td
>
101
</
td
>
<
td
>
rahul
</
td
>
<
td
>
dumdum
</
td
>
<
td
>
Management
</
td
>
</
tr
>
</
tbody
>
<
tbody
>
<
tr
>
<
td
>
102
</
td
>
<
td
>
suman
</
td
>
<
td
>
kulti
</
td
>
<
td
>
Accountant
</
td
>
</
tr
>
</
tbody
>
</
table
>
<
button
id
=
"btndel"
onclick
=
"removerow()"
>
Remove row
</
button
>
Jqery code
function removerow()
{
$(
"#tblGrid"
).find(
"tr:gt(0)"
).remove();
}
Jquery
Delete Table Rows
Up Next
Jquery Delete All Table Rows Except First