0

I want to use jQuery's remove() function to remove an item from the DOM.

The problem is that remove() requires a selector and I already have a reference to the element I want to remove in an object.

Given an element reference, say tableRow, is there any way to remove that element?

2
  • that should work too Commented Apr 30, 2015 at 20:46
  • If tableRow is a jquery object then just run remove on it tableRow.remove() Commented Apr 30, 2015 at 20:47

1 Answer 1

4

This should work:

tableRow.remove(); 

or

$(tableRow).remove(); 
Sign up to request clarification or add additional context in comments.

1 Comment

Ah yes, looking at the jQuery documentation more carefully, I do see that the selector is optional.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.