在 javascript 操作表格时,可以用 table.rows[i].cells[j] 的方法引用到 指定 的单元格,那怎么 写个table[i][j]的函数来 封装一下 table.rows[i].cells[j],使得 用起来 更方便 呢? 拜托了 ,各位大虾!!
解决方案 »
- 求js模拟alert()方法的阻塞功能
- extjs 左边tree菜单,右边tabpanel中显示grid等信息的问题。
- []==[]输出ture或者false? []==![]输出ture或者false?
- 正则匹配字符串,应该算简单的吧,在线等,立结贴
- 我这段代码在FireFox 下不能正常运行了
- 求firefox兼容的右键菜单,谢谢了!
- jsp运行servlet发现调用的一个类找不到,但是本地运行又是对的
- 帮忙看看这个呢?javascript不是很熟悉!已经很长时间了!感觉有点难
- 各位大侠: 帮帮忙吧!
- 一个很初级的javascript问题
- 对象冒充后,为何要删除被冒充的对象呢?不删除会有什么不好,有代码为例
- 音乐播放器代码
<style>
td {width:50px;border:1px solid red;}
</style>
<script type="text/javascript">
function getCell(tb,i,j){
if(typeof tb === "string" ) return document.getElementById(tb).rows[i].cells[j];
return tb.rows[i].cells[j];
}
function getCellText(tb,i,j){
if(typeof tb === "string" ) return document.getElementById(tb).rows[i].cells[j].innerText;
return tb.rows[i].cells[j].innerText;
}
</script>
<input type="button" value="隔空摘星" onclick="alert('第2行第2列是:'+getCellText('tb1',1,1));" />
<table id=tb1>
<tr onclick="alert('第2行第2列是:'+getCell(this.parentNode,1,1).innerText);"><td>11</td><td>22</td></tr>
<tr><td>33</td><td>44</td></tr>
</table>
function getCell(tb,i,j){
if(typeof tb === "string" ) return document.getElementById(tb).rows[i].cells[j];
return tb.rows[i].cells[j];
}
function getCellText(tb,i,j){
return getCell(tb,i,j).innerText;
}