[问题] JS上使用Click没有反应

楼主: oklp1415 (天生我材)   2016-01-03 09:55:35
我要做的事情是,当我按下Button按钮,会自动执行JSON内的资料内容,并把宣告的
JSON资料填入到Table中,但是我卡关的地方,按下Click后都没有反应
不知道是我哪里理解有错误,希望有人可以指导一下!!感谢,附上我撰写的Code
<fieldset>
<form>
<input type="button" value="显示名称"
onclick="getTemp(#temp_div)" />
</form>
<table>
<div id="temp_div"></div>
<tr>
<th>User_Name</th>
<th>score</th>
<th>team</th>
</tr>
</div>
</table>
</fieldset>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var json = [
{"User_Name":"1","score":"100","team":"1"},
{"User_Name":"2","score":"80","team":"2"},
{"User_Name":"3","score":"90","team":"2"}
{"User_Name":"4","score":"33","team":"2"}
{"User_Name":"5","score":"38","team":"2"}
{"User_Name":"6","score":"64","team":"2"}
];
var tr;
for (var i = 0; i < json.length; i++) {
tr = $('<tr/>');
tr.append("<td>" + json[i].User_Name + "</td>");
tr.append("<td>" + json[i].score + "</td>");
tr.append("<td>" + json[i].team + "</td>");
$('table').append(tr);
}
});
</script>
作者: f7811202002 (天蝎男完全体)   2016-01-03 15:14:00
你的getTemp function?
作者: ht5603 (Mike)   2016-01-04 01:08:00
#temp_div加单引号

Links booklink

Contact Us: admin [ a t ] ucptt.com