表格操作

1.获取单元格内容

    

 1 <table id="tab">
 2      <thead>
 3             <tr>
 4                   <th>姓名</th>
 5                   <th>性别</th>
 6                   <th>操作</th>
 7              </tr>
 8      </thead>
 9      <tbody>
10               <tr>
11                     <td>test</td>
12                      <td>male</td>
13                      <td>删除</td>
14                </tr>
15                 <tr>
16                     <td>test1</td>
17                      <td>female</td>
18                      <td>删除</td>
19                </tr>
20       </tbody>
21 </table>

  var oTab = document.getElementById("tab");

  a. alert(oTab.children[0].children[1].children[1]); 

  b. alert(oTab.tBodies[0].rows[1].cells[1]) ;                       //tHead(只能有一个), tBodies, rows, cells            

         

原文地址:https://www.cnblogs.com/yiliweichinasoft/p/3817520.html