event.srcElement

捕捉当前活动对象;很好用的一个东西!
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
  <script>
  function tdclick()
 {
    var td = event.srcElement;
    alert(td.tagName);
    alert(td.outerHTML);
    alert(td.innerText);
 }
  </script>
 </HEAD>

 <BODY>
  <table id="tab1" width="85%" onclick="tdclick();" border="1" align="center">
 <tr>
  <td align="center" style="cursor:hand">11</td>
  <td align="center" style="cursor:hand">12</td>
  <td align="center" style="cursor:hand">13</td>
  <td align="center" style="cursor:hand">14</td>
 </tr>
 <tr>
  <td align="center" style="cursor:hand">21</td>
  <td align="center" style="cursor:hand">22</td>
  <td align="center" style="cursor:hand">23</td>
  <td align="center" style="cursor:hand">24</td>
 </tr>
  </table>
 </BODY>
</HTML>

你可能感兴趣的:(element)