I'm trying to detect when a checkbox is checked or unchecked in jQuery. I'm creating the checkboxes dynamically from JSON content. This is how they are created:
$.each(data.modifierOptions, function(key, item) {
var checkBox = "<input type='checkbox' class='modifier' data-name='" + item.Name + "' + data-price='" + item.Price + "' name='" + item.Name + "' value='" + item.ID + "'/>" + item.Name + "<br/>";
$(checkBox).appendTo('#modifiersDiv');
});
Now, viewing the source of the body I'm getting this:

Finally, I'm trying to get the checked/unchecked event with this jQuery event, but nothing happens:
$('input:checkbox.modifier').change(function () {
var sThisVal = (this.checked ? $(this).val() : "");
});
How can I solve this?
Update
I want to get the event by checkbox class.
mousedown()event listener instead ofchange().