<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<script type="text/javascript">
var str = "";
str += "<table width=500 border=1 rules=all align=center>";
str += " <tr bgcolor='#ccffff'>";
str += " <th>编号</th><th>新闻标题</th><th>发布时间</th>";
str += " </tr>";
var a = 1;
while(a<=100)
{
str += " <tr bgColor='#ccff00'>";
str += " <td>第<font color=red>"+a+"</font>行</td><td> </td><td> </td>";
str += " </tr>;"
a++;
}
document.write(str)
</script>
<title>Document</title>
</head>
<body>
</body>
</html>
上边的点点点是咋回事啊.
@忆先 说的是对的,题主是不小心把分号放进来了吧?
另外这种循环拼接字符串的方式性能较差,建议用数组存取每次拼接的HTML,然后用arr.join('');
for循环的第三行引号里面多了一个分号。