求助,怎么给table的id号赋值? <TABLE height=32 cellSpacing=0 cellPadding=0 width=93 border=0 id="1">如上,怎么给id="1" 赋值,变成id="1" id="2" 循环 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这样?<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <head> <script> window.onload=function(){ var div = document.getElementById("1"); alert(div.id); div.id=2; alert(div.id); } </script> </head> <body> <DIV id="1"></DIV> </body></HTML 呵呵... 应该不是LZ想要的 LZ还是请把问题描述清楚吧 <html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script language="javascript" type="text/javascript"> window.onload = function () { var tables = document.getElementsByTagName("table"); for (var i = 0; i < tables.length; i++) { //遍历页面上的table 并设置他的Id属性 //也可直接通过 tables[i].id=i设置 tables[i].setAttribute("id", i); tables[i].onclick = function () { alert(this.id); } } alert("共有" + tables.length + "table,点击后查看table的ID"); } </script></head><body> <table summary="table1"> <tr><td>table1</td></tr> </table> <table summary="table2"> <tr><td>table2</td></tr> </table> <table summary="table3"> <tr><td>table3</td></tr> </table></body></html>是这样吗? 貌似ID以数字开头不会出bug,,只是不规范而已 Javascript 获取控件在整个屏幕的坐标 setTimeout()为啥停不下来? javascript 参数问题! 如何用javascript中promot获得参数实现跳转到任意页 JS 提交 提交ACTION页面 出现问题 (急) js释放资源的问题 求utf8转gb2312方法 如何让弹出的窗口在最上方 读取文件,替换一定的内容后给另外的一个页面(document.write),字符转换的问题 为何js字符不能跨行?如果能跨行,编辑起来要方便很多的:) 【大家帮忙看看这段小程序】 JS如何判断本地客户端是否安装outlook
<HTML>
<head>
<script>
window.onload=function(){
var div = document.getElementById("1");
alert(div.id);
div.id=2;
alert(div.id);
}
</script>
</head>
<body>
<DIV id="1"></DIV>
</body>
</HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script language="javascript" type="text/javascript">
window.onload = function () {
var tables = document.getElementsByTagName("table");
for (var i = 0; i < tables.length; i++) {
//遍历页面上的table 并设置他的Id属性
//也可直接通过 tables[i].id=i设置
tables[i].setAttribute("id", i);
tables[i].onclick = function () {
alert(this.id);
}
}
alert("共有" + tables.length + "table,点击后查看table的ID");
}
</script>
</head>
<body>
<table summary="table1">
<tr><td>table1</td></tr>
</table>
<table summary="table2">
<tr><td>table2</td></tr>
</table>
<table summary="table3">
<tr><td>table3</td></tr>
</table>
</body>
</html>
是这样吗?
貌似ID以数字开头不会出bug,,只是不规范而已