I need to add and remove items from one list to another on click. Here is fiddle
Idea is that on "Add" button click <li>Item</li> goes to second list on first place and that on "Remove" button click <li>Item</li> goes to first list on first place.
I want option that I can click several times on buttons and move items from list to list.
Html:
<ul id="listOne">
<li>Item 1 <button type="submit" id="add">Add</button></li>
<li>Item 2 <button type="submit" id="add">Add</button></li>
<li>Item 3 <button type="submit" id="add">Add</button></li>
</ul>
<ul id="listTwo">
<li>Item 4 <button type="submit" id="remove">Remove</button></li>
<li>Item 5 <button type="submit" id="remove">Remove</button></li>
<li>Item 6 <button type="submit" id="remove">Remove</button></li>
</ul>
Jquery: (I have low-knowledge)
function moveItems(origin, dest) {
$(origin).find('li').appendTo(dest);
}
$('#add').click(function () {
moveItems('#listOne', '#listTwo');
});
$('#remove').on('click', function () {
moveItems('#listTwo', '#listOne');
});