`
cbbs
  • 浏览: 40325 次
  • 来自: ...
文章分类
社区版块
存档分类
最新评论

支持IE和Firefox的得到表格的当前行号和列号

阅读更多
<table border="1">  <tr>
    <td><table   border=1>
        <tr>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我</td>
        </tr>
        <tr>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我</td>
        </tr>
        <tr>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我</td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td><table   border=1>
        <tr>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我1</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我1</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我1</td>
        </tr>
        <tr>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我1</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我1</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我1</td>
        </tr>
        <tr>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我1</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我1</td>
          <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'><table   border=1>
              <tr>
                <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我5</td>
                <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我5</td>
                <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我5</td>
              </tr>
              <tr>
                <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我5</td>
                <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我5</td>
                <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我5</td>
              </tr>
              <tr>
                <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我5</td>
                <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我5</td>
                <td   onclick='alert("行数:"+(this.parentNode.rowIndex+1)+"\n列数:"+(this.cellIndex+1))'>点我5</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>

 

分享到:
评论

相关推荐

    javascript 移动鼠标得到单元格所在table表中的rowIndex位置[兼容ie,firefox] <font color=red>原创</font>

    本文主要介绍了如何兼容IE和Firefox浏览器,在用户移动鼠标时获取单元格所在的行索引位置(rowIndex)和列索引位置(cellIndex)。在编写跨浏览器的脚本时,了解不同浏览器之间在事件处理方面的差异至关重要。 在IE...

    IE 中使用 Console

    在 IE 中,虽然其内置的开发者工具可能与其他现代浏览器(如 Chrome 或 Firefox)有所不同,但基本的 `console` 方法如 `log`, `warn`, `error` 等依然可用。 ### 一、开启 IE 开发者工具 1. 在 IE 浏览器中,按下...

    JGrid

    JGrid对浏览器的兼容性也是一大亮点,它不仅支持现代的Firefox浏览器,还兼容较为老旧的IE6。这意味着无论用户使用何种浏览器,都能享受到一致的表格体验,这对于开发者来说,无疑减轻了在不同浏览器上进行调试的...

    在web中js实现类似excel的表格控件

    Handsontable兼容多种浏览器,包括IE7+、Firefox、Chrome、Safari以及Opera。为了在项目中使用Handsontable,你需要引入一系列库文件。首先,确保已经添加了jQuery,因为Handsontable依赖于jQuery进行DOM操作。接着...

    前端网站相关笔试题

    - **实现**: 获取用户输入的行号和列号,检查有效性,并修改对应单元格的文本内容。 - **优点**: 提供了修改表格内容的功能。 - **不足**: 用户输入验证较简单,可能无法完全避免非法输入。 #### 五、总结 通过...

    SinaEditor编辑器整和插入代码功能

    SinaEditor是新浪公司推出的一款开源富文本编辑器,它基于JavaScript开发,支持多种浏览器,如IE、Firefox、Chrome、Safari等。该编辑器具有丰富的插件系统,能够实现如图片上传、视频插入、表格编辑等多种功能,极...

    前端开发面试题

    - 第四个参数(可选):错误的列号。 - 第五个参数(可选):错误对象。 #### IE与Firefox的事件对象的不同点 - **IE**:使用 `window.event` 来访问当前事件对象。 - **Firefox**:事件处理函数的第一个参数通常...

    table insertRow、deleteRow定义和用法总结

    在IE浏览器中,可以直接调用`table.insertRow()`,但在Firefox等其他遵循W3C标准的浏览器中,需要指定插入位置,即`table.insertRow(-1)`,表示在表格末尾插入新行。此方法接受一个可选参数`index`,用于指定插入新...

Global site tag (gtag.js) - Google Analytics