0

我正在jsfiddle上尝试它......我不知道它为什么不运行............有人帮助

html section
<html>
    <body>
        <div>The Answer is: </div>
        <div class='answer'></div>
    </body>`enter code here`
</html>


js section
function writeAnswer(answer) { // helper function for output
    $('div.answer').append($('<div>').text(answer));
}

function writedemo() {
    var answer="hello";
    writeAnswer(answer);

    }

}

writedemo();
4

2 回答 2

2

工作演示 http://jsfiddle.net/zJ3yk/

因为你有额外的}

休息应该有助于满足需求:)

代码

function writeAnswer(answer) { // helper function for output
    $('div.answer').append($('<div>').text(answer));
}

function writedemo() {
    var answer="hello";
    writeAnswer(answer);

    }
//} <===== this is the culprit and rest demo gives you idea. 

writedemo();​
于 2012-08-01T06:18:47.377 回答
0

检查以下jsfiddle。你可以找到工作的js。

http://jsfiddle.net/shivkant/HQyZe/8/

于 2012-08-01T06:24:46.313 回答