jQuery - dynamically append and remove ordered items
Posted: 10 Jan 2015, 15:40
I'm trying to dynamically add and remove items with jQuery when I press the Append /Remove buttons.
This is the html code:
How do I make it so that when I press #btn1 multiple times it will add each time a <li> element with an ordered number after it? Like this:
Then if I press #btn2 it will remove the last item?
This is the html code:
Code: Select all
<ul id="lists">
<li>List Item 0</li>
</ul>
<button id="btn1">Append List</button>
<button id="btn2">Remove List</button>
Code: Select all
List Item 1
List Item 2
List Item 3