Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

What is the best method for removing a table row with jQuery?

like image 809
Darryl Hein Avatar asked Oct 04 '08 21:10

Darryl Hein


People also ask

How add and remove row from table in jQuery?

remove() method we can dynamic add and delete row using jquery. append() method is used for append or add rows inside an HTML table and . remove() method to remove or delete table rows as well as all data inside it from the DOM dynamically with jquery.

How can remove TD value in jQuery?

closest("td"). prev(). html(""); }); This will remove all content in previous td tag.

How do you delete a row in a table JavaScript?

To delete rows in a table in JavaScript, use the DOM deleteRow() method.


1 Answers

You're right:

$('#myTableRow').remove(); 

This works fine if your row has an id, such as:

<tr id="myTableRow"><td>blah</td></tr> 

If you don't have an id, you can use any of jQuery's plethora of selectors.

like image 108
imjoevasquez Avatar answered Oct 07 '22 17:10

imjoevasquez