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:

  1. You should really start using jQuery :)

    ReplyDelete
  2. Why don't you use the delete operator?

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

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

    ReplyDelete