JavaScript Reference/Javascript Methods/replaceNode

Материал из Web эксперт
Перейти к: навигация, поиск

"replaceNode()" Example

    
<html>
<body>
<script language="JavaScript">
function function1() {
   var newElement = document.createElement("u");
   newElement.innerHTML = "Text";
   var oldElement = document.all.myBold;
   document.all.myBold.replaceNode(newElement); 
} 
</script>
<button onclick="function1();">Replace text</button>
<div id="myDiv" style="width:300; height:200; border:solid black 1px;">Sample 
    <b id="myBold">text</b>
</div>
</body>
</html>



"replaceNode()" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<a>                             <acronym>                     |
|                |<address>                       <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="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>                          <object>                      |
|                |<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>                         |
+----------------+--------------------------------------------------------------+



"replaceNode()" Syntax, Parameters and Note

Note:
Replaces an node with a new node.
    
Syntax:
    
document.all.elementID.replaceNode(param1)
Parameters:
    param1   Required; the replacement node.