asp.net.ph

Skip Navigation Links

replaceNode Method

DHTML Methods


Replaces the object with another element.

Syntax

object.replaceNode ( oNewNode ) 
Parameters

oNewNode Required. Specifies the new element to replace the object.

Return Value

No return value.

Remarks

When a node is replaced, all values associated with the replaced object are removed. For example, if a B object is replaced with an I object, any attributes and text between the opening and closing tags are also replaced. To preserve these values, they can be copied to the new element before the original object is replaced.

Example

The following sample demonstrates the use of the replaceNode method to replace an unordered list with an ordered list.

<script language="JavaScript">
function fnReplace ( ) {
  var sPreserve = oList.innerHTML;
  var oNewNode = document.createElement ( "OL" );
  oList.replaceNode ( oNewNode );
  oNewNode.innerHTML = sPreserve;
}
</script>

<UL ID = oList>
   <LI>List Item 1
 <LI>List Item 2
 <LI>List Item 3
 <LI>List Item 4
</UL>
<input TYPE = button VALUE = "Replace List" 
  onclick = "fnReplace ( ) ">
See Also

replaceChild



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note