Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • what is jquery apppendTo() method?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 378
    Comment on it

    Hello Readers,

    appendTo() is the jquery method which is used to insert the any HTML elements at the end of the given selector as a parameter into the appendTo() method.

    Syntax :

    $(content).appendTo(selector)
    

    Parameters :

    content : it is a required parameter which specifies the content to insert at the end.

    selector : it is also a required parameter which specifies on which elements to append the content to.

    Code Example :

    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("button").click(function(){
            $("<span>Hello World!</span>").appendTo("p");
        });
    });
    </script>
    </head>
    <body>
    
    <button>Insert element</button>
    
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    
    </body>
    </html>
    

    In the above code, we use the button on click of button append the HTML string to the selector p tag at the end.

 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: