奇怪的javascript问题与比较

时间:2011-08-08 10:37:47

标签: javascript

我在一个函数中有这个小部分,只有当我在检查前有警告框时才进行比较。

如果我删除它,它会说它总是等于2或更高...但是当我有警报框时,它显示我们不相等但它仍然有效。

为什么?感谢

[编辑:添加了整个函数,el_id是被按下的div,它有2个属性,你可以看到,但它们不会导致问题]

 function PostAnswer(el_id) {
    var a = $("#"+el_id).attr("answer");
    var u = $("#"+el_id).attr("player");

    // mark question as answered
    players_have_answered = players_have_answered + 1;
    if (a == game_questions[current_question][5]) {
        // CORRECT
        current_question = current_question + 1;

        // stop the clock and reset
        stop_clock();

        alert('Player '+u+' is correct!');
    } else {
        // WRONG!
        $("#lbl_u" + u + "_q").html("<span class='sub'>Wrong answer!</span>");
    }

    alert(u + " player pressed: " + players_have_answered + " vs " + player_count);
    if (player_count == players_have_answered) {
        // stop the clock and reset
        stop_clock();
        alert('No player correct!');
    }
}

0 个答案:

没有答案