How to destroy a DOM element with jQuery?

Viewed 165226

Suppose the jQuery object is $target.

4 Answers

Not sure if it's just me, but using .remove() doesn't seem to work if you are selecting by an id.

Ex: $("#my-element").remove();

I had to use the element's class instead, or nothing happened.

Ex: $(".my-element").remove();

Related