Dynamically creating checkboxes through JQuery and associating an action to it

// wont work
$(".questionCheckbox").click( function() {
alert("hi");
});
// will work
$(document).on('click', '.questionCheckbox', function(){
alert('test');
});
// during an ajax response
$("#questions").append("<input type=checkbox class=questionCheckbox value="+object.id+">"+object.question+"<br>");

Leave a Reply

Your email address will not be published. Required fields are marked *