我正在创建并附加一些元素复选框。之后,如果我想要复选复选框的值,我有问题:
$('#step-1').find('.checkbox').live('click', function() {
alert($(this).attr('val')); // return correct value
alert($(this).val()); // return strong 'no'
});
答案 0 :(得分:1)
尝试使用this.value
:
$('#step-1').find('.checkbox').live('click', function() {
if(this.checked){ //if the checkbox is checked
alert(this.value);
}
else {}
});