vendredi 6 janvier 2017

Appending only the new selected checkbox not the previouse one

Hi so my issue is that i have a table and I add what the user is typing and when a new tr is added a new checkbox is added the thing is when i mark the checkbox and press show result it appears but when i press another checkbox the previouse checkbox and the new checkbox appears How can i append only the checkbox that i'm marking ? Here's my code:

$(document).ready(function(){

$(".btn-default").on("click",function(){
    var textval = $('.form-control').val();
    $('.list').append("<input type='checkbox' class='check'/> " + textval + '<br />');


    $('body').on("click", ".check" , function() {
        var textcopy = textval;
        if( $(".check").prop('checked') ) {
            $(".showCompleted").append("<tr><td>"+  textcopy+"</td></tr>");
        } 
    });

});

$(".btn-info").on("click",function(){
    $(".completed").removeClass("hide");
})

});




Aucun commentaire:

Enregistrer un commentaire