All I'm trying to do is bind the change event of some checkboxes, by class - and then determine if the checkbox is being checked or unchecked for further processing (unrelated to my current problem).
The "nope" alert pops, no matter what - and I have no idea why. I've read a couple related threads and the code that I've posted appears to be working for others.
HTML:
<asp:CheckBox ID="cbNewMembers" runat="server" Checked="true" Text="New Members" CssClass="GreenControl CheckOption" />
<asp:CheckBox ID="cbLostMembers" runat="server" Checked="false" Text="Lost Members" CssClass="GreenControl CheckOption" />
<asp:CheckBox ID="cbIncludeOnline" runat="server" Checked="false" Text="Include Online Apps" CssClass="GreenControl CheckOption" />
jQuery:
$(document).ready(function (e) {
$(".CheckOption").on("change", function () {
if ($(this).is(":checked"))
alert("yep");
else
alert("nope");
});
});
Note that I've also tried:
if (this.checked)
and
if ($(this).prop("checked") == "checked")
and a few other combinations. But, like I said, the if statement always evaluates as false. Please help!
Aucun commentaire:
Enregistrer un commentaire