jeudi 3 mars 2022

Click checkbox with jQuery

I'm building html dynamically with Ajax.

This code generates my table:

$(".row-info").append(`
    <div class="items_container ${value}" id="${value}">
        <div class="col-md-2 item_ref">${value}</div>
        <div class="col-md-6 item_description">${response[0].nombre}</div>
        <div class="col-md-3"><input type="number" class="form-control" value="1" style="width: 100%; text-align:center" /></div>
        <div class="col-md-1"><i class="fas fa-trash-alt fa-2x text-danger remove_line" style="cursor:pointer;"></i></div>
    </div>
`);

$(".remove_line").on("click", function () {
    $(".items_container." + value).remove();
    $("." + value).click();
});

enter image description here

This image it's result for my table created dynamically. I have a red trash image that if clicked it removes a line from the table.

I need to do that when I click remove checkbox checked, but when I clicked in this checkbox, change message.

I tried with: $('.'+value).click(); but my problem is that duplicate my entry in my table, always I can show my item selected. My message change, because detect when it's checked or not. But never remove my table line.

I don't know if have better solution to do this. And solve my problem.

Resume: when i click in checkbox "OFERTA" in left window, create iframe in right. When i check one checkbox in Iframes right I need create table resume in bottom.

Thanks for reading and sorry for my english.




Aucun commentaire:

Enregistrer un commentaire