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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 119
    Comment on it

    This method is used to make a copy of matched elements. Using this method we can also makes a copies of their child nodes, texts, and attributes. In another words it makes the duplicate of the matched elements.
    Syntax :

    $(selector).clone(true|false)
    

    Parmeters :
    True : It specifiy if event handlers should be copied.
    Fasle :It specify if event handlers should not be copied
    Example :
    HTML Code :

    <html>
    <head></head>
    <body>
    <p>Hello Mukesh Tomar</p>
    <button>Click to make copies of p tag content and add in the body elements</button>
    </body>
    </html>
    

    jQuery Code :

    $(document).ready(function(){
      $("button").click(function(){
        $("p").clone().appendTo("body") // make copy of p tag elements and append to body elements
    });
    });
    

    Output :
    Hello Mukesh Tomar

    Hello Mukesh Tomar // whenever you click on above button, it will make a new copy of that p tag elements

 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: