此表未显示在我的html文件中:任何人都可以看到明显的错误吗?我已经盯着它好几个小时了!
<div id="data_list">
<script type="text/javascript">
document.write("<table border='1' rules='rows' cellspacing='0'>")
document.write("<tr>");
document.write("<th>Date</th><th>Amount</th><th>First Name</th>");
document.write("<th>Last Name</th><th>Address</th>");
document.write("</tr>");
for (i=0;i<=amount.length;i++){
if (i%2=0){
document.write(<tr>);
}else{
document.write("<tr class='yellowrow'>");
}
document.write("<td>" + date[i] + "</td class='amt'>" + amount[i]+ "</td>");
document.write("<td>" +firstName[i] + "</td><td>" + lastName[i] + "</td>");
document.write("<td>" + street[i] + "<br />" + city[i] + ", " +state[i]+ "" + zip[i] + "</td>");
document.write("</tr>");
}
document.write("</table>");
</script>
答案 0 :(得分:2)
下面:
if (i%2=0){
document.write(<tr>);
}else{
document.write("<tr class='yellowrow'>");
}
应该是
if (i%2==0){
document.write('<tr>');
}else{
document.write("<tr class='yellowrow'>");
}
i%2=0
应为i%2==0
此外,<tr>
应为字符串'<tr>'