How to bind click and change event for checkbox
checkbox, javascript, jquery
Solution
Try .on()
Fiddle Demo
$(document).on("click change", "#filterOptions input[name=inNeedAmountRange]", function () {
var elementValue = this.value;
if ($(this).is(':checked')) {
alert('checked : ' + elementValue);
} else {
// ^ remove extra }
alert('Not checked :' + elementValue);
}
});
Event Delegation
Problem
I am adding some checkbox to the page through ajax how to bind the click and change function for these checkboxes my script is here ``` $(document).delegate("#filterOptions input[name=inNeedAmountRange]").bind("click change", function () { var elementValue = $(this).val(); if ($(this).is(':checked')) { alert('checked : ' + elementValue); } } else { alert('Not checked :' + elementValue); } }); ```