I'm in the process of developing a task manager that enables users to add and remove tasks. I am also working on enabling the ability for users to transfer tasks from one list to another. The current code I have written doesn't seem to be functioning as expected, and I suspect there might be an issue within my JavaScript implementation.
HTML:
<input type='checkbox' id="togglelist1" class='arrow'/>
<label for="list1menu">
<input type="text" name="newlist1" value="" spellcheck="false" placeholder="New List" id="newlist1">
<ul id="list1UL">
<li><input type="checkbox" id="newlist1item" class="right-margin"/><label>List1</label> <button type="button" class="deletelist"> </button> <button type="button" class="addtolist2"></button></li>
</ul>
</label>
<input type='checkbox' id="togglelist2" class='arrow'/>
<label for="list2 menu">
<ul id="list2UL" class='list2UL'>
<li><input type="checkbox" id="newlist2item" class="right-margin"/><label>List2</label> <button type="button" class="deletelist"></button></li>
</ul>
</label>
JavaScript:
$(() => {
$('input').on('keypress', function(e) {
if (e.keyCode == 13) {
const newList1 = $(this).val();
if (newList1) {
var li = $("<li><input type='checkbox' id='newlist1item' class='right-margin'/><label>List1</label> <button type='button' class='deletelist'> </button> <button type='button' class='addtolist2'></button></li>");
$('#list1UL').append(li);
$(this).val("");
localStorage.setItem("list1UL", value);
}
}
});
$(document).on("click", ".deletelist", function() {
$(this).parent().remove();
});
$(".addtolist2").on( "click", function() {
$(".addtolist2").css("opacity", 1.5 - $(".addtolist2").css("opacity"));
$(".addtolist2").toggleClass("list2UL");
$('#list1UL input:checked').parent().clone().appendTo('#list2UL');
});
});
CSS:
#togglelist1 {
cursor: pointer;
position: absolute;
background: url('list1.png') no-repeat;
height: 30px;
width: 30px;
background-size: 100%;
display: none;
}
#togglelist2 {
cursor: pointer;
position: absolute;
background: url('addtolist2.png') no-repeat;
background-size: 100%;
display: none;
}
____List 1____
label[for="list1menu"] {
display: none;
text-decoration: none;
position: absolute;
bottom: 250px;
left: 250px;
width: 680px;
height: 540px;
}
...
____List 2____
label[for="list2menu"] {
display: none;
text-decoration: none;
position: absolute;
bottom: 250px;
left: 250px;
width: 680px;
height: 540px;
}
...