vendredi 17 janvier 2020

I want to set my checkbox on "checked" when i click a specific td in my table

Hei guys. I want my Checkbox to be "checked" after i click the last td field of a row. I tried it with JQuery but unfortunately i always checked all checkboxes. I just want to check the td at the row i clicked.

Thats how i build my table.

<table class="table table-striped" id="notfallTable">
    <tr>
        <th value="name">Name</th>
        <th>Nachname</th>
        <th>Nummer</th>
        <th>Abteilung</th>
        <th id="thCheckbox"><button id="checkAll" class="btn btn-success">Check all</button>
        </th>
   </tr>
</table>
$.getJSON("NotfallSMS.json", function(data){
    var items=[];
    var checkbox="test";
    $.each(data, function(key, val){
        items.push("<tr>");
        items.push("<td contenteditable>"+val.Name+"</td>");
        items.push("<td contenteditable>"+val.Nachname+"</td>");
        items.push("<td contenteditable>"+val.Nummer+"</td>");
        items.push("<td contenteditable>"+val.Abteilung+"</td>")
        items.push("<td class='check'><input class='check' type='checkbox'>"+""+"</input></td>");

        items.push("</tr>");
    });
    $("<tbody/>", {html: items.join("")}).appendTo("table");
});

I hope you can help me out. Greetings Elfdow




Aucun commentaire:

Enregistrer un commentaire