Development| HTML| JavaScript| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
JavaScript cloneNode example 
 

As it is clear with its name that it clones the node. JavaScript cloneNode() method creates a clone copy of the given node object and returns the clone node object.

 

JavaScript cloneNode example

                         

As it is clear with its name that it clones the node. JavaScript cloneNode() method creates a clone copy of the given node object and returns the clone node object. In our this sample code we have created a clone node copy of the button object.

Syntax:

 elementObject.cloneNode(boolean);

It accepts only one argument of boolean type which is not mandatory. If its value is "false" it doesn't include the child nodes and if its "true" then it will include the child nodes as well.

Description of code:

In our example code for creating a clone of given node object we have created a page in which we have included a button with the id "button" when user clicks on it then it calls functionClone(), which is defined in our JavaScript function that it will clone the node object by getting the button object with the id "button". It will show the clone object in the alert message. Full source code for it is as given below:

cloneNodeExample.html

<html>
 <head>
   <title>Clone Node example</title>
     <script language="JavaScript">
	function functionClone(){
	   var clonenode = button.cloneNode(true);
	   alert("created clone node"+clonenode);
	   document.getElementById("button").disabled=true;
	} 
     </script>
  </head>
  <body>
     <p align="center">&nbsp;</p>
     <div style="background: #cf2255; width:'100%';"
          align="center">
     <font color="#ffffcc" size="12pt">
       <b>Creating Clone Node</b>
     </font>
     </div>
       <center>
	<p>
	 <button id="button" 
                 onclick="functionClone();">
                      Create clone node
         </button>
	</p>
	</center>
	</body>
</html>

Output:

click on the "Create clone node" button

Download Source Code

                         

» View all related tutorials
Related Tags: java javascript html c table script delete object header method ip page oo create tab footer with e il it

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.