我在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();
答案 0 :(得分: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();
答案 1 :(得分:0)
检查以下jsfiddle。你可以找到工作的js。