For some reason, the following code does not work properly:
<input onclick="$(function(){ alert($(this).attr('checked')); })" name="step1[agree]" id="step1_agree" value="1" type="checkbox">
It alerts with undefined. I have also tried doing something like this:
onclick="$(function(){ var chk=$(this); alert(chk.attr('id')); })"
... but ends up with the same result. What am I doing wrong and how can I fix this?
<input onclick="alert($(this).attr('checked'));" name="step1[agree]" id="step1_agree" value="1" type="checkbox">
But a better option would be
<input name="step1[agree]" id="step1_agree" value="1" type="checkbox">
$('#step1_agree').click(function() {
alert($(this).attr('checked));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With