3

那是代码:

function pagechange(frompage, topage) {
    var page = document.getElementById('formpage_' + frompage);
    if (!page) return false;
    page.style.visibility = 'hidden';
    page.style.display = 'none';

    page = document.getElementById('formpage_' + topage);
    if (!page) return false;
    page.style.display = 'block';
    page.style.visibility = 'visible';

    return true;
}

var currentShown = "";

function unhide(rad) {
    var id = "answer" + rad.id.replace("-", "");
    var answer = document.getElementById(id);
    if (answer) {
        var current = document.getElementById(currentShown);
        if (current) current.className = "hidden";
        currentShown = id;
        answer.className = "unhidden";
    }
}

var score = 0;

function scoreIncrement() {
    score++;
    document.getElementById("score").innerHTML = score;
}

http://jsfiddle.net/NSzxN/

然后这是我的带有该代码的网站页面:

http://elearning.easy2dev.com/quiz_template_3.php

单击 John 时,它应该将分数增加 1,然后在下方显示答案框,没有任何反应,但在 JS Fiddle 中它可以工作。它曾经可以工作,但我似乎以某种方式破坏了它。

4

1 回答 1

5

如果您将 FireFox 与 FireBug 扩展一起使用,您会看到以下错误:

illegal character in quiz_t...e_3.php at line 61:
}​
-^

其中指的是以下代码:

function scoreIncrement() {
    score++;
    document.getElementById("score").innerHTML = score;
}​ // <<-- mysterious zero-length character here
</script>
于 2012-04-04T09:50:40.917 回答