How to use HTML Clone Method in JQuery

This article describe about HTML Clone Method in JQuery.
  • 1924

HTML clone() method in jQuery

Clone() method is used to create a copy for the selected element.

clone method is copied to all element for the selected position.

In this method event handler is not used.

Syntax

$(selector).clone(includeEvents)

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function ()

{

        $("button").click(function ()

{

            $("p").clone().appendTo("body");

        });

    });

</script>

</head>

<body>

<p>This is a JQuery.</p>

<button>Clone all p elements after click this button</button>

</body>

</html>

Output1

op1.jpg

Output2

op2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.