-->

jQuery clone() Method

By: Bipin C Mathew 7 months, 2 weeks ago

The clone is a Jquery HTML/CSS Method. It is used to make copies of element. We can also make copies of child nodes with texts and attributes with clone method.

Syntax:

$(selector).clone(true|false)

Parameter: It accepts an optional parameter which could be either true or false specifies that event handler should be copied or not.

Example:

<html> 

<head> 
	<script src="https://ajax.googleapis.com/ajax/libs/ 
			jquery/3.3.1/jquery.min.js"></script> 
				
	<!--In this example no parameter is passing to the 
		clone method-->
	<script> 
		$(document).ready(function() { 
			$("button").click(function() { 
				$("p").clone().appendTo("body"); 
			}); 
		}); 
	</script> 
</head> 

<body> 
	<p>Welcome to</p> 
	<p>Atemon !!!</p> 
	<!--click on this method and see the clone element-->
	<button>Click Me!</button> 
</body> 

</html> 

Comments

Let us talk!

We take the vision which comes from dreams and apply the magic of science and mathematics, adding the heritage of our profession and our knowledge to create a design.