javascript - Tracking checkbox event using jquery -
i have following code:
$("#chkbx_first").change(function () { if ($(this).attr("checked")) { alert("check box selected"); //do when checked } else { alert("check box unselected"); //do when cleared }
the problem despite on checkbox stste second allert appears time - "check box unselected". why first alert doesn't appear ?
is there approaches track check event? thanx.
try if (this.checked)
or use .prop()
$("#chkbx_first").change(function () { if (this.checked) { // or if($(this).prop("checked")){ alert("check box selected"); //do when checked } else { alert("check box unselected"); //do when cleared } }
Comments
Post a Comment