Home  >  jQuery

Example of .clone() in jQuery

April 28, 2013
.clone() in jQuery, clones the value of one element and can append with the value of another element. .clone() is used as
$("i").clone().prependTo("p")
 
Here the value of <i></i> will be added to <p></p> paragraph. Find the example.

<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
  <i>Hello World!</i>
  <p>It is jQuery World.</p>
 <script>
  $("i").clone().prependTo("p");
</script>
 </body>
</html>
 

Output
Hello World!

Hello World!It is jQuery World.

FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us