I need a jQuery function that does the following: for example, when checked checkbox1, when I click on some other elements (with an identifier starting with element-), I could print idthese elements in the console:
$('#checkbox1').click(function() {
if ($(this).is(':checked')) {
$(document).on('click','[id^=element-]', function(e) {
console.log(this.id);
});
} else {}
});
I tested this example and did not work. I do not know when I am wrong.
source
share