Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use jQuery clone () Method ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 235
    Comment on it

    Hi Reader's,
    Welcome to FindNerd, today we are going to discuss how to use jQuery clone () Method ?

    The clone () Method is used for making a copy of matched element.This Method makes the
    duplicate of the matched elements. clone () Method also makes a copies of their child nodes, texts, and attributes.
    syntax of clone () Method

    $(selector).clone(true|false)
    

    There are two main parameter of above given syntax
    1-True:-It specify if event handlers should be copied.
    2-False:-It specify if event handlers should not be copied.

    you can take reference of below example:

    <html>
    
      <head>
        <!-- here define jquery library file -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <script>
        $(document).ready(function(){
        $("button").click(function(){
        $("p").clone().appendTo("body") // make copy of p tag elements and append to body elements
        });
        });
    
       </script>
    </head>
    
        <body>
        <!--  define a paragraf  -->
        <p>Hi joe ! How are you ?</p>
        <button>Click to copy</button>
    
        </body>
        </html
    

    The output of the code above will be:

     Hi joe ! How are you ?  
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: