欢迎光临
我们一直在努力

to hiller:利用脚本控制表格单元的内容(原创)

建站超值云服务器,限时71元/月

现在终于找到相关资料,做完了例子这个发现msdn中也有一个类似的例子,呵呵!!

<script language="javascript">
function changecell(r,c){
var content=prompt("清输入内容:");
kk.rows(r).cells(c).innerhtml=content;
}
</script>
<body>
<table id=kk width=100% cellspacing=1 cellpadding=1 border=1>
<tr><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td> </td><td> </td><td> </td><td> </td></tr>
</table>
<input type="text" id=row> <input type="text" id=col><br>
<input type="button" value="changecell" onclick=changecell(parseint(row.value),parseint(col.value))>
</body>

解释:
rows和cells在table中分别代表着行和列的集合,在table中的范围限于thead, tbody, tfoot。
使用方法:obj.rows(index)
         obj.cells(index)
其中index是可选的,可以选择一个整数索引也可以选择一个字符串作为索引。
整数索引是基于0开始的,也就是说基和中的第一个元素的下标是0。
字符串索引必须是一个有效的至少存在于页面中的一个具有标示的元素名称。
我不知道翻译的是否正确,下面附上msdn中的原文:
optional. an integer or a string specifying the index value of the element to retrieve. integer indexes are zero-based, meaning the first element in the collection has index 0. a string index is valid only if the string is an identifier of at least one element in the document.

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » to hiller:利用脚本控制表格单元的内容(原创)
分享到: 更多 (0)

相关推荐

  • 暂无文章