HOW TO USE APPEND() METHOD IN JQUERY.

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 489  View(s)
Ratings:
Rate this:
I want to use append() method in jquery. how to do this please help me.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: How to use append() method in jquery.

    when we want to add dynamically data to existing elements  in html using jquery. we can use append() method in jqery.

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="Scripts/jquery-2.1.4.js"></script>
    </head>
    <body>
    <a href="javascript:void(0);" onclick="AppendList();">Append List</a>  
    <ul id="ullist"></ul>

    <script type="text/javascript">
        function AppendList() {
            var item1 = $("<li></li>").text("Item 1");
            var item2 = "<li>Item 2</li>";
            var item3 = document.createElement("li");
            item3.innerHTML = "Item 3";
            $("#ullist").append(item1, item2, item3);
        }
    </script>
    </body>
    </html>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!