<!DOCTYPE?html>
<html>
????<head>
????????<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/>
????????<title>挑戰題</title>
????????<script?src="http://libs.baidu.com/jquery/1.9.0/jquery.js"?type="text/javascript"></script>
????????<style>
????????????td{border:1px?solid?red}
????????</style>
????????
????</head>
????<body>
????????<input?type="button"?id="btn"?value="clickMe"?/>
????????<table?id="myTable"?style="border:1px?solid?red;border-collapse:collapse">
????????????<tr>
????????????????<td>姓名</td>
????????????????<td>年齡</td>
????????????????<td>身高</td>
????????????????<td>配偶</td>
????????????????<td>婚姻批言</td>
????????????</tr>
????????</table>
????????
????????
????????<script>
????????$(document).ready(function(){
????????????var?students=[
????????????????{"name":"羅琛","age":"22","height":"150","mate":"金穎婕","comment":"金玉良緣"},
????????????????{"name":"姜磊","age":"22","height":"180","mate":"金穎婕","comment":"金石為開"},
????????????????{"name":"金穎婕","age":"22","height":"160","mate":"搞不清楚","comment":"無能為力"},
????????????????];
????????????????
????????????????$('#btn').bind("click",function(){
????????????????????$.each(students,function(index,student){
????????????????????????$('table').append("<tr><td>"+student.name+"</td><td>"+student.age+"</td><td>"+student.height+"</td><td>"+student.mate+"</td><td>"+student.comment+"</td></tr>");
????????????????????});?
????????????????});?
????????????});
????????????????
????????</script>
????</body>
</html>
2016-06-03
如果在 HTML 表單中使用 button 元素,不同的瀏覽器會提交不同的值。Internet Explorer 將提交 <button> 與 <button/> 之間的文本,而其他瀏覽器將提交 value 屬性的內容。請在 HTML 表單中使用?input 元素來創建按鈕。