zoukankan      html  css  js  c++  java
  • 第五周(生成动态表格)

    这是这周敲的一段代码,继续努力!知道怎样生成动态表格啦,以后做个人网页的时候或许能用到呢。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>无标题文档</title>

    <script type="text/javascript">

    function init(row,col)

    {

         var str="<table border='1' width='300' height='300'>"     

          for(var i=1;i<=row;i++)     

    {

               str+="<tr>";           

           for(var j=1;j<=col;j++)           

    {

                      str+="<td id='img0' onClick='judge("+((i-1)*col+j)+");'>"+((i-1)*col+j)+"</td>";

               }     

    str+="</tr>";      }     

    str+="</table>"     

    document.getElementById("mt").innerHTML=str; }

    function createTable()

    {       var row=document.getElementById("t1").value;

          var col=document.getElementById("t2").value;

          init(row,col); }

    function judge(temp)

    {     

    alert(temp);  }

    {/script>

    </head>

    <body>

    <div id="mt">text</div>

    <input type="text" value="3" id="t1"/>

    <input type="text" value="3" id="t2"/>

    <input type="button" value="生成表格" onClick="createTable();"/>

    </body>

    </html>

  • 相关阅读:
    编写可读性代码的艺术
    web前端常见的加密算法介绍
    git 遇到的问题
    Vue.js使用proxytable跨域的路径问题
    设置动画元素
    解决echarts图表在显示没有数据后再切换后渲染不出的问题
    svn回滚到之前的版本
    插件用法--视频播放video.js
    网页适配
    不跳转页面下载文件
  • 原文地址:https://www.cnblogs.com/aztl/p/5323717.html
Copyright © 2011-2022 走看看