-1
I am trying to make a list of tasks to be simple where you have inserted tasks dynamically, there is a checkbox in each task that when being checked puts a line-through in the text, but in doing this he always puts in the first tasks and the others does nothing, I wonder if you have how to identify each one, keeping it dynamic, follows below the code
$(document).ready(function(){
$(document).keypress(function(e) {
if(e.which == 13) $('#button').click();
});
$('#button').click(function(){
var textAdd = $('#inpudAdd').val();
$('#inpudAdd').val('');
$('#div').append('<div id = divinha><input class = "mano" id = "check" type="checkbox"> ' + textAdd +'<img id = "lixo" src="imagens/lixeira.png" alt="" height="20px">' +'</div>');
});
$(document).on("change","#check",function(){
if ($(this).is(":checked"))
{
$('#divinha').addClass('marcar');
}
else
{
$('#divinha').removeClass('marcar');
}
});
/*$(document).on("click.primeiro",'#check', function() {
$('#divinha').addClass('seila');
console.log("meu");
});
$(document).on("click.segundo",'#check', function() {
$('#divinha').removeClass('seila')
console.log("meu");
});*/
$(document).on("click",'#lixo', function() {
if(confirm("Voce realmente deseja excluir esse item?")==true){
$('#divinha').remove();
}
});
});
.marcar{
text-decoration: line-through;
}
.CentralizarDiv{
width: 50%;
margin: auto;
height: 70vh;
overflow: auto;
}
.centralizarInp{
width: 50%;
display:block;
margin: 0 auto;
padding: 10px 0 10px 0;
margin-top: 10px;
margin-bottom: 20px;
}
.centralizarBut{
width: 50%;
display:block;
padding: 10px 0 10px 0;
margin: 0 auto;
margin-top: 10px;
margin-bottom: 10px;
}
h2{
width: 50%;
margin: auto;
}
table{
width: 50%;
margin: 0 auto;
}
.secBut{
width: 100%;
padding: 10px 0 10px 0;
}
<html>
<head>
<link rel="stylesheet" href="css/css.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src = "js/js.js"></script>
</head>
<body>
<h2>Lista de Tarefas</h2>
<input class="centralizarInp" type="text" name="checkListItem" id="inpudAdd"/>
<button class = "centralizarBut " id="button">OK</button>
<table >
<tr><td><button id = "incopleto" class="secBut">Em Progresso</button></td>
<td><button id = "completo"class="secBut">Finalizadas</button></td>
<td><button id = "todos" class="secBut">Todos</button></td>
</tr>
</table>
<div class="CentralizarDiv" id= "div" ></div>
</body>
</html>
Thank you so much, you helped so much!
– Lucas Castro