亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么代碼中要用<input type="button" id="btn" value="clickMe">而不能用<button id="btn"></button>

<!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>


正在回答

1 回答

如果在 HTML 表單中使用 button 元素,不同的瀏覽器會提交不同的值。Internet Explorer 將提交 <button> 與 <button/> 之間的文本,而其他瀏覽器將提交 value 屬性的內容。請在 HTML 表單中使用?input 元素來創建按鈕。

0 回復 有任何疑惑可以回復我~
#1

littleKnife 提問者

雖然沒有理解,但還是非常感謝
2016-06-03 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
jQuery基礎課程
  • 參與學習       154733    人
  • 解答問題       7289    個

加入課程學習,有效提高前端開發速度

進入課程

為什么代碼中要用<input type="button" id="btn" value="clickMe">而不能用<button id="btn"></button>

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號