JS删除练习
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> #tbList { margin: 10px auto; border-collapse: collapse; /*是否合并为单一边框*/ } </style> <script type="text/javascript"> var arr = [{ "title": "一个C#问题", "name": "张三", "date": "2014-05-24" }, { "title": "一个C#问题", "name": "张三", "date": "2014-05-24" }, { "title": "一个C#问题", "name": "张三", "date": "2014-05-24" }, { "title": "一个C#问题", "name": "张三", "date": "2014-05-24" }, { "title": "一个C#问题", "name": "张三", "date": "2014-05-24" } ]; window.onload = function () { loadData(); //方法不能写在这里面 } function loadData() { var tb = document.getElementById("tbList"); var trNew = document.createElement("tr"); for (var j = 0; j < arr[i].length; j++) { var td1 = document.createElement("td"); td1.innerHTML = arr[i].title; trNew.appendChild(td1); tb.appendChild(trNew); } } </script> </head> <body> <table id="tbList" border="1"> <tr> <td>序号</td> <td>标题</td> <td>发件人</td> <td>发件时间</td> </tr> </table> </body> </html>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。