用JS 循环做一个表格


<!DOCTYPE html>

<html>

 <head>

<meta charset="utf-8" />

<title></title>

 </head>

 <body>

 </body>

<script type="text/javascript">

//首先设置行,列

var cols = 6; //6列

var rows = 6; //6行

var htmlstr = "<table border='1px'>";

for(i = 1; i <= rows; i++) {

htmlstr += "<tr>";

for(j = 1; j <= cols; j++) {

htmlstr += "<td >" + i + "行" + j + "列" + "</td>";

}

htmlstr += "</tr>";

}

htmlstr += "</table>";

document.write(htmlstr);

</script>

 </html>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM