Reputation: 839
I'm creating and append to some element some checbox. After that, if I want the value of checked checbox, I have problem:
$('#step-1').find('.checkbox').live('click', function() {
alert($(this).attr('val')); // return correct value
alert($(this).val()); // return strong 'no'
});
Upvotes: 1
Views: 233
Reputation: 146302
Try using this.value
:
$('#step-1').find('.checkbox').live('click', function() {
if(this.checked){ //if the checkbox is checked
alert(this.value);
}
else {}
});
Upvotes: 1