removeChild method
Removes a child node from the object.
![]() |
Syntax
object.removeChild(oldChild)Parameters
- oldChild [in]
-
Type: IHTMLDOMNode
Object that specifies the element to be removed from the document.
Return value
Type: IHTMLDOMNode
Returns a reference to the object that is removed.Standards information
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.
Windows Internet Explorer 9. Exceptions are only supported when webpages are displayed in IE9 Standards mode.
In Microsoft Internet Explorer 6, This method now applies to the attribute object.
Examples
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.\nPage will be refreshed when you click OK.") document.location.reload(); } } </script> </head> <body> <div id="Div1" onclick="removeElement()"> Click anywhere in this sentence to remove this <strong>Bold</strong> word. </div> </body>
See also
- a
- abbr
- acronym
- address
- attribute
- b
- bdo
- big
- blockQuote
- body
- button
- caption
- center
- cite
- code
- col
- colGroup
- comment
- dd
- del
- dfn
- dir
- div
- dl
- documentType
- dt
- em
- fieldSet
- font
- form
- frameSet
- head
- hn
- html
- i
- iframe
- input type=button
- input type=checkbox
- input type=email
- input type=file
- input type=hidden
- input type=image
- input type=number
- input type=password
- input type=radio
- input type=range
- input type=reset
- input type=search
- input type=submit
- input type=tel
- input type=text
- input type=url
- ins
- kbd
- label
- legend
- li
- listing
- map
- marquee
- menu
- nextID
- ol
- option
- p
- plainText
- pre
- ProcessingInstruction
- q
- s
- samp
- select
- small
- span
- strike
- strong
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- tr
- tt
- u
- ul
- var
- xmp
Show:
