I have a data set that I loop through and make rows of checkboxes along with other data. The user should have the ability to click on the checkbox to toggle whether something else should be showing. For some reason, $('label').click() never gets called. Code:
let i = 0;
data.forEach((row) => {
myTable += "<tr>" + "<td>" + `<label id="label" for=` + String(i) + `><input type="checkbox" id=` + String(i) + `><span> Not showing</span></label>` + "</td>"+ "<td>" + row.name + "</td>" + "<td>" + app.nations[row.nation] + "</td></tr>"
$('label').click(function() {
console.log("Clicked");
var checked = $('input').is(':checked');
$('span').text(checked ? ' Showing' : ' Not showing');
});
i += 1;
});
Thanks!