0

Every searches I made only included solutions for variables like this: $('#div'+ id)

I need to delete a row.

var row = $(this).parent().parent().parent().find('tr#' + id).html();

I'd like to use the "row" name instead of "$(this)...remove();"

3 Answers 3

6

like

$('tr[name='+rowname+']').remove()
Sign up to request clarification or add additional context in comments.

Comments

4

use .closest, it is safer than all those chained parent calls in case you change the markup which will break the code.

var row = $(this).closest('tr');
row.remove()

Comments

1

Just populate the row var with a reference to the row.

var row = $(this).parent().parent().parent().find('tr#' + id);
var html = $(row).html();
$(row).remove();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.