Monday, 18 January 2010

Deleting stuff with javascript

Would you like to clean house with js without messing around with hidden stuff? Piece of cake:

document.getElementById("thing_to_delete").parentNode.removeChild(document.getElementById("thing_to_delete"));

Yes, it's kinda weird, just like referring to myself as "the son of my father", but it actualy works.

3 comments:

Dave said...

You should really start using jQuery :)

Ale said...

Why don't you use the delete operator?

Unknown said...

@Dave, te ghe resùn... prima o poi migro :D

@Alessandro: si può? con che sintassi? :)