jQuery复选框值bug(?)

时间:2011-06-23 15:42:18

标签: jquery checkbox

我正在创建并附加一些元素复选框。之后,如果我想要复选复选框的值,我有问题:

$('#step-1').find('.checkbox').live('click', function() {
    alert($(this).attr('val')); // return correct value
    alert($(this).val()); // return strong 'no'
});

1 个答案:

答案 0 :(得分:1)

尝试使用this.value

$('#step-1').find('.checkbox').live('click', function() {
    if(this.checked){ //if the checkbox is checked
        alert(this.value);
    } 
    else {}
});