Write a jQuery code to add list elements within an unordered list element.

 Write a jQuery code to add list elements within an unordered list element.


Write a jQuery code to add list elements within an unordered list element.

Answer : 
File Name : jQuery.html

<html>
<head>
    <script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
    <title>SP Creation</title>
</head>
<body>
    <div class="container">
        <div class="col" id="box">
            <ul>
                <li>Item 1</li>
                <li>Item 2</li>
                <li>Item 3</li>
                <li>Item 4</li>
            </ul>
        </div>
        <button id="add">Add</button>
    </div>
    <script>
        $(document).ready(function(){
            $("#add").click(function(){
                $("ul").append("<li>Item NEW</li>");
            });
        });
    </script>    
</body>
</html>
Write a jQuery code to add list elements within an unordered list element. Write a jQuery code to add list elements within an unordered list element. Reviewed by technical_saurabh on April 30, 2021 Rating: 5

No comments:

Powered by Blogger.