js九九乘法表的应用

<html>
<head>
<meta charset=utf-8" />
<title>js九九乘法表</title>
<style type="text/css">
table {
    width: 800px;
    height: 300px;
    border-collapse: collapse;
}
table th {
    border: 1px solid #069;
}
</style>
</head>
<body>
<script type="text/javascript">
    document.write("<table>");
    var str = "js九九乘法表";
    document.write("<h1>" + str + "</h1>");
    for ( var x = 1; x <= 9; x++) {
        document.write("<tr>");
        for ( var y = 1; y <= x; y++) {
            document.write("<th>" + x + "*" + y + "=" + (x * y) + "</th>");
        }
        document.write("</tr>");
    }
    document.write("</table>");
</script>
</body>
</html>

    border-collapse: collapse;//用于表格属性, 表示表格的两边框合并为一条

 

 
posted @ 2017-04-05 16:43  缘琪梦  阅读(230)  评论(0编辑  收藏  举报