Syntax verification for removing an element

Giganews Newsgroups
Subject: Syntax verification for removing an element
Posted by:  Don Li (tatata99…@gmail.com)
Date: Wed, 26 Mar 2008

Hi,

I'm under the impression that the following code would remove an
element, and I've tested it with IE7.  I commented out two lines in
between for I read somewhere that claimed they are not meaninful, your
thought?  Thanks.

function removeElementBy(el) {
        rem = document.getElementById(el);
        // if (rem.parentNode && rem.parentNode.removeChild(rem)) {
        rem.parentNode.removeChild(rem);
      //}
    }

Replies