zoukankan      html  css  js  c++  java
  • JavaScript向表格中添加按钮和文本输入框

    例子:

    <?php 
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
        input
        {
            200px;
            height:50px;
            color:#eaeaea;
            border-color:red;
        }
    </style>
      <script>
          function modifyTableContent()
          {
              var obj = document.getElementById("tab1");
              obj.rows[1].cells[1].innerHTML = "<button>按键</button>";
              obj.rows[1].cells[0].innerHTML = '<input type="text" value="coding for fun!"/>';
          }
      </script>
    </head>
    
    <body>
    <table id="tab1" width="445" border="1">
      <tr>
        <th width="200" scope="col">编号</th>
        <th width="200" scope="col">姓名</th>
        <th width="200" scope="col">登录名</th>
        <th width="200" scope="col">身份</th>
        <th width="200" scope="col">创建时间</th>
        <th width="200" scope="col">登录时间</th>
      </tr>
      <tr>
        <th width="200" scope="col">23</th>
        <th width="200" scope="col">Jack</th>
        <th width="200" scope="col">xman</th>
        <th width="200" scope="col">马甲</th>
        <th width="200" scope="col">09-11</th>
        <th width="200" scope="col">09-13</th>
      </tr>
    </table>
    <button style=" 60px; height:30px" onclick="modifyTableContent()"></button>
    </body>
    </html>
  • 相关阅读:
    js--DOM基本使用
    前端--js基础2
    前端--js基础1
    tcp/udp编程
    关于网络
    异常处理
    装饰器
    1.__new__ 魔术方法 单态(例)模式 __del__ 魔术方法(析构方法) __call__ 魔术方法
    面向对象程序设计及面向对象封装 目录
    script 标签里的 async 和 defer
  • 原文地址:https://www.cnblogs.com/Robotke1/p/3321389.html
Copyright © 2011-2022 走看看