JavaScript Reference/Javascript Methods/cloneNode

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

"cloneNode()" Example

   <source lang="javascript">
   

<html> <body> <script language="JavaScript"> function function1(){

   var myNode = myButton.cloneNode(true);
   alert(myNode.innerHTML); 

} </script> <button id="myButton" onclick="function1();">Clone node</button> </body> </html>


     </source>
   
  


"cloneNode()" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<a> <acronym> | | |<address> <applet> | | |<area> attribute | | | <base> | | |<basefont> | | |<bgsound> |

| |
<body> |

| |
<button> |

| |
|

| | | | |<col> <colgroup> | | |<comment>

| | | |

| |<dir>
| | |
| | | <embed> | | |<fieldset> | | |<form> <frame> | | |<frameset> <head> | | |<hn>
|

| |<html> | | |<iframe> <img> | | |<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"> | | | <isindex> | | | <label> |

| |<legend>
  • | | |<link> <listing> | | |<map> <marquee> | | |<menu> <meta> | | |<noframes> <noscript> | | |<object>
      | | |<optgroup> <option> | | |

      <param> | | |<plaintext>

                               |
      |                |                                                        |
      |                |                          <script>                      |
      |                |<select>                                               |
      |                |                                                |
      |                |                        <style>                       |
      |                |                                                    |
      |                |                         <tbody>                       |
      |                |                          |
      |                |                             
        | | | <xmp> | +----------------+--------------------------------------------------------------+ </source>

        "cloneNode()" Syntax, Parameters and Note

        <source lang="javascript"> Note: Creates a copy of the current node. After an element is cloned, referring to the id of that element returns a collection.

        Syntax:

        document.getElementById("elementID").cloneNode(param1) document.all.elementID.cloneNode(param1) // IE only

        Parameters: param1 Optional; either true or false, indicating whether or not you want to clone child nodes as well.


        </source>

      <textarea> | | |<tfoot> |

      | |<thead> <title> |

      | |