美文网首页
js基础2作业10

js基础2作业10

作者: HavenYoung | 来源:发表于2018-08-20 19:40 被阅读0次

html

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>

    <body>
        <table border="" cellspacing="" cellpadding="">
            <tr>
                <th id="head" colspan="10">用for循环打印十行十列表格,表格里面写1-100,并且隔列变色</th>
            </tr>
            <link rel="stylesheet" type="text/css" href="css/question10.css" />
            <script src="js/question10.js"></script>
        </table>

    </body>

</html>

css

.even{
    height: 25px;
    width: 100px;
    background-color: beige;
}

.odd{
    height: 25px;
    width: 100px;
    background-color: gold;
}

js

var count = 1
for(var row = 0; row < 10; row++){
    document.write("<tr>")
    for(var column = 0; column < 10; column++){
        if(!(column%2)){
            document.write("<td ")
            document.write("id=")
            document.write(row,column)
            document.write(" class='odd'>")
        }else{
            document.write("<td ")
            document.write("id=")
            document.write(row,column)
            document.write(" class='even'>")
        }
        document.write(count)
        document.write("</td>")
        count++
    }
    document.write("</tr>")
}


结果图


jsHomework10.png

相关文章

  • js基础2作业10

    html css js 结果图

  • JS + Git 测试小练习

    作业链接 js 基础练习js 扩展练习(section-1 & section-2) 提交记录 练习收获 这次作...

  • js基础3作业2

    秒表

  • js基础2作业11

    自己实现随机 a, b 之间的整型

  • 2018-12-20

    1.01.尚硅谷_JS基础_JS简介(1) 10.10.尚硅谷_JS基础_Null和Undefined(10) 1...

  • 第一篇:了解Vue

    [TOC] Vue的基础 Vue概述:2014/2 Vue.js正式发布;2015/10/27 正式发布1.0.0...

  • 小程序系列--JS基础

    JS基础 最后一遍JS基础,需要一定的语言基础 1. JS在网页中使用 2. 注释 3. 变量 声明变量 var...

  • js基础2

    1.事件 1)添加事件 点击事件:onclick 2)图片显隐 出现: 3)this的用法 在匿名函数中的this...

  • js基础2

    一、js引入方式和打印方式 四种引入方式(1) 百度一下 (2) (3)在html页面的任何位置加入 js代码...

  • JS基础2

    函数 主要参考:https://wangdoc.com/javascript/types/function.htm...

网友评论

      本文标题:js基础2作业10

      本文链接:https://www.haomeiwen.com/subject/jyxriftx.html