www.fgks.org   »   [go: up one dir, main page]

Click to Rate and Give Feedback
Methods
 removeChild Method
removeChild Method

Removes a child node from the object.

Syntax

oRemove = object.removeChild(oNode)

Parameters

oNode Required. Object that specifies the element to be removed from the document.

Return Value

Returns a reference to the object that is removed.

Remarks

The node to be removed must be an immediate child of the parent object.

This method is accessible at run time. If elements are removed at run time, before the closing tag is parsed, areas of the document might not render.

In Microsoft Internet Explorer 6, This method now applies to the attribute object.

Example

This example uses the removeChild method to remove a bold element from a div.

<HEAD>
<SCRIPT>
function removeElement()
{
  try
  {
      //The first child of the div is the bold element.
    var oChild=Div1.children(0);	
    Div1.removeChild(oChild);
  }
  catch(x)
  {
    alert("You have already removed the bold element. 
      Page will be refreshed when you click OK.")
    document.location.reload();
  }
}
</SCRIPT>
</HEAD>
<BODY>
<DIV ID=Div1 >
Click anywhere in this sentence to remove this <B>Bold</B> word.
</DIV>
</BODY>

Standards Information

This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 World Wide Web link.

Applies To

A, ABBR, ACRONYM, ADDRESS, attribute, B, BDO, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DEL, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FONT, FORM, FRAMESET, HEAD, hn, HTML, I, IFRAME, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, nextID, OL, OPTION, P, PLAINTEXT, PRE, Q, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP
Tags What's this?: Add a tag
Community Content
 
Add Community Content
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker
DCSIMG