How to use HTML AppendTo Method in JQuery

This article describe about HTML AppendTo Method in JQuery.
  • 2138

HTML appendTo() method in jQuery

The appendTo method is used to insert an element on the selected position.

This appendTo method add the element at the end position of the selected element.

The Append method and AppendTo method both are same thing but the syntax will be different.

Syntax

$(content).appendTo(selector)

Example

<!DOCTYPE html>

<html>

<head>

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

<script type="text/javascript">

    $(document).ready(function ()

{

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

 {

            $("<b>Hello World!</b>").appendTo("p");

        });

    });

</script>

</head>

<body>

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

<p>This is .Netheaven.</p>

<button>Insert content 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.