zoukankan      html  css  js  c++  java
  • 使用this作为方法的参数

    <table>

    <tbody>

      <tr id="test"><td></td></tr>

    </tbody>

    </table>

    document.getElementById("test").setAttribute("onclick","Test()");

    var Test=function(){

      alert(Object.prototype.toString.call(this));

    };

    结果显示: [object Window]

    要想取得tr,正确的做法是:

    document.getElementById("test").setAttribute("onclick","Test(this)");

    var Test=function(row){

      alert(row.cells.length);

    };

    结果显示:1

    正确了,呵呵.

  • 相关阅读:
    Tree MapByFold
    Tree DepthByFold
    Tree SizeByFold
    Tree MaximumByFold
    Tree Fold
    Tree Map
    Tree Depth
    Tree Maximum
    Tree Size
    Tree
  • 原文地址:https://www.cnblogs.com/hongjiumu/p/2676315.html
Copyright © 2011-2022 走看看