I have a list with the header to do whose elements I can pass to the list that has the header Done:
It works correctly for me to move the elements from one list to the other, but I'm not sure how I can eliminate the item from the list that I clicked on.
When the x is pressed (in the code it is a span with class delete), the task must be deleted and it must not be passed to the other list.
$(document).ready(function() {
$('.todo').on('click', 'li', function() {
$(this).appendTo('.done');
});
$('.done').on('click', 'li', function() {
$(this).appendTo('.todo');
});
});
body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.list {
display: inline-block;
width: 330px;
vertical-align: top;
margin: 0 50px;
}
ul {
font-size: 18px;
background-color: #f5f5f2;
padding: 0;
min-height: 50px;
border: 1px solid #DBDBD3;
}
ul li {
position: relative;
color: #66665D;
list-style-type: none;
padding: 20px;
cursor: pointer;
border-bottom: 1px solid #DBDBD3;
}
ul li:last-child {
border-bottom: none;
}
ul.done li {
color: #ABABA4;
text-decoration: line-through;
}
ul .delete {
position: absolute;
top: 20px;
right: 10px;
color: #ccc;
font-weight: bold;
text-shadow: 1px 1px white;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="wrapper">
<div class="list">
<h3>Por hacer:</h3>
<ul class="todo">
<li>Sacar la ropa <span class="delete">x</span></li>
<li>Lavar los platos <span class="delete">x</span></li>
<li>Hacer la cama <span class="delete">x</span></li>
<li>Leer un rato <span class="delete">x</span></li>
<li>Terminar este reto <span class="delete">x</span></li>
<li>Sacar al perro <span class="delete">x</span></li>
</ul>
</div>
<div class="list">
<h3>Hecho:</h3>
<ul class="done">
</ul>
</div>
</div>