0

我想在函数中使用 $.each 。但是我的返回值有问题,应该在每个函数中覆盖它。

function validate_voting_stars() {
    $error = false;
    $.each( $('input.rr'), function(index,value){
        vote = $(this).val();
        if( $.isNumeric($(this).val() ) && vote < 6 ) {
            return;
        } else {
            $error = true;
        }
    })
    return $error;
}

我认为,返回值的触发不是等待完成 jQuery 的每个函数。有没有办法,我怎么能解决这个问题?为了测试,我在每个函数中添加了返回,但这也不起作用

有任何想法吗?

4

1 回答 1

1

尝试

function validate_voting_stars() {
    $error = false;
    $.each( $('input.rr'), function(index,value){
        vote = $(this).val();
        if( !$.isNumeric($(this).val() ) || vote > 6 ) {
            $error = true;
            return false;
        }
    })
    return $error;
}
于 2013-04-27T11:18:21.897 回答