Remove An Element By Id Using Javascript

Here is a useful function to remove any element by id using Javascript.

Related Posts Plugin for WordPress, Blogger...

9 comments

  1. Sometimes I’m just chocked with the lack of straight-forward functions in javascript…
    I mean… element.remove(); would be something you would expect built-in

    my code below =D
    Object.prototype.remove = function(){
    this.parentNode.removeChild(this);
    }

    now you can do element.remove();

  2. nevermind… javascript doesn’t create Object type objects for elements you get… I wonder what is the return type of the getElementById function… undefined???

  3. cool but how to do this in the address bar like
    javascript:and the code here how to remove something with id got from getElementById() ???

Leave a Reply

Your email address will not be published. Required fields are marked *