zy's profile张宇PhotosBlogLists Tools Help

Blog


    April 17

    得到当前列的列号

    //得到当前列的列号
    function getCurrentColNo(tdObject)
    {
     var tableObject = getTableRootByTd(tdObject);
     var current_row_no = getCurrentRowNo(tdObject);
     var current_row_td_num = tableObject.rows[current_row_no].cells.length;
     for(var i=0;i<current_row_td_num;i++)
     {
      if(tableObject.rows[current_row_no].cells[i] == tdObject)
      {
       return i;
      }
     }
    }

    得到当前行的行号

    //得到当前行的行号
    function getCurrentRowNo(tdObject)
    {
     var tableObject = getTableRootByTd(tdObject);
     for(var i=0;i<tableObject.rows.length;i++){
      if(tdObject.parentNode == tableObject.rows[i]){
       return i;
      }
     }
    }