I tried to implement checkbox checked event, but seems cannot trigger it to new elements added to the list. Here is the jquery code.
$("#button").click(function() {
var toAdd = $("input[name=ListItem]").val();
$("ul").append(
`<li class="" id=` +
generateID() +
`><input name="name" type="checkbox" class="name" />` +
listName +
`</li>`
);
});
$('input[type="checkbox"]').click(function() {
if ($(this).prop("checked") == true) {
alert("Checkbox is checked.");
} else if ($(this).prop("checked") == false) {
alert("Checkbox is unchecked.");
}
});
<ol>
<li id="1" class="">
<input name="name" type="checkbox" class="name"> List Name1
</li>
</ol>
Thank you