jQuery prepend() data

Total Post:4

Points:28
JQuery 
 410  View(s)
Ratings:
Rate this:

I want to add another item using jquery on button click

<ol>
  <li>List item 1</li>
  <li>List item 2</li>
  <li>List item 3</li>
</ol>
<button id="btn1">add item</button>


  1. Post:1

    Points:7
    Re: jQuery prepend() data

    you need to add the following code

    <script>
    
    $(document).ready(function(){
        $("#btn1").click(function(){
            $("ol").prepend("<li>item</li>");
        });
    });
    </script>


Answer

NEWSLETTER

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