How to remove div elements in javascript using their id?

Possible duplicate:
JavaScript: delete item by ID

I know only their identifiers and do not know specifically about their parent nodes ....

+5
source share
2 answers

You can use parentNodefor an element to get its parent element, and use removeChildon it.

var el = document.getElementById( 'id' );
el.parentNode.removeChild( el );
+22
source

In jQuery will work only $('#your_id').remove();.

+19
source

All Articles