Good afternoon.
I need to check if a dynamically created checkbox (is within a modal) is checked. As it was created dynamically, I thought of the following code:
$(document).ready(function () {
$(document).on('click', '#elemento', function () {
if($(document).on("input[id='elemento']:checked")) {
alert('Sim');
} else {
alert('Não');
}
});
});
The problem is that this function always returns true. I can not use this.checked because it will reference the document, not the checkbox. I can not understand what's wrong. Anyone have any ideas?