• 如何得到table里面的ID


    <html>
     <head>
      <title>Table Test</title>
      <meta name="generator" content="Editplus" />
      <meta name="author" content="PJ" />
      <script language="JavaScript">
      <!--
       function Delete()
       {
          var dgTable=document.getElementById('tb').rows;//tb为table的ID,
          var pp=window.event.srcElement; 
          for (var i=0; i < dgTable.length; i++) //遍历table的行,
          {
             if(pp==dgTable[i].cells[2].getElementsByTagName("A")[0]) //cells[2]为触发事件的列的索引
             { //判断是否是触发事件的A标签
                alert(dgTable[i].cells[0].innerText); //演示,弹出所在行的第一列的内容    
             } 
          }
       }
      //-->
      </script>
     </head>
     <body>
      <table id="tb" border="1px" width="500px">
      <tbody>
      <tr>
       <td width="40%">aaa</td>
       <td width="40%">bbb</td>
       <td width="15%"><a onClick="Delete()" href="#">delete</a></td>
      </tr>
      <tr>
       <td>ccc</td>
       <td>ddd</td>
       <td><a onClick="Delete()" href="#">delete</a></td>
      </tr>
      <tr>
       <td>eee</td>
       <td>fff</td>
       <td><a onClick="Delete()" href="#">delete</a></td>
      </tr>
      </tbody>
      </table>
     </body>
    </html>

  • 相关阅读:
    Pascal's Triangle II
    Pascal's Triangle
    Path Sum II
    Path Sum
    plusOne
    Divide Two Integers
    64. ZigZag Conversion
    63. Swap Nodes in Pairs && Rotate List && Remove Nth Node From End of List
    62. Divide Two Integers
    61. Unique Paths && Unique Paths II
  • 原文地址:https://www.cnblogs.com/zcy_soft/p/1868274.html
Copyright © 2020-2023  润新知