请教高手,我是个新手,请问怎么用js获得数组对象的index function catchindex(obj) { i = 0; while (obj.tagName != "DIV") { i++; alert(document.all[obj.sourceIndex + i].tagName); } } 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 稍微修改了一下希望对大家有帮助<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>catchindex</title><script language="javascript"><!--function catchindex(obj){for(var i=0;i<5;i++){var DivObj=document.all[obj.sourceIndex + i] if (DivObj.tagName == "DIV") { //i++; //alert(document.all[obj.sourceIndex + i].tagName); if(DivObj.style.display=="none") DivObj.style.display="" else DivObj.style.display="none" }}}//--></script></head><body><table id="idtable"><tr id="idtr" onmouseover="catchindex(this)" onmouseout="catchindex(this)"><td id="idtd">1</td></tr><tr><td><div id="iddiv" style="display:none">this is div1</div></td></tr><tr id="idtr" onmouseover="catchindex(this)" onmouseout="catchindex(this)"><td id="idtd">2</td></tr><tr><td><div id="iddiv" style="display:none">this is div2</div></td></tr><tr id="idtr" onmouseover="catchindex(this)" onmouseout="catchindex(this)"><td id="idtd">3</td></tr><tr><td><div id="iddiv" style="display:none">this is div3</div></td></tr></table></body></html> 这句是怎么做的? 免费web打印控件,推荐一个 JS菜鸟求助 如何检查在TEXT中输入的字符? xmlhttprequest访问时如何取到<meta http-equiv="refresh" content="1; url=http://www.quchen.com.cn"> 中的url 求一正则表达式 请教一个关于 Frame 的问题! 防止重复提交(UP有分)急 如何创建js动态数组 --->> ■■请教,JS中定义变量,在网页中引用变量怎么不行啊,大家给看看,例如:■■ 关于对象的onresize事件,急问!多谢了 关于bt1.btchina.net网页加密的问题,老鸟请进!Up没分!
希望对大家有帮助
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>catchindex</title>
<script language="javascript">
<!--
function catchindex(obj)
{
for(var i=0;i<5;i++)
{
var DivObj=document.all[obj.sourceIndex + i]
if (DivObj.tagName == "DIV")
{
//i++;
//alert(document.all[obj.sourceIndex + i].tagName);
if(DivObj.style.display=="none")
DivObj.style.display=""
else
DivObj.style.display="none"
}
}
}//-->
</script>
</head><body><table id="idtable">
<tr id="idtr" onmouseover="catchindex(this)" onmouseout="catchindex(this)">
<td id="idtd">
1
</td>
</tr>
<tr>
<td>
<div id="iddiv" style="display:none">this is div1</div>
</td>
</tr>
<tr id="idtr" onmouseover="catchindex(this)" onmouseout="catchindex(this)">
<td id="idtd">
2
</td>
</tr>
<tr>
<td>
<div id="iddiv" style="display:none">this is div2</div>
</td>
</tr>
<tr id="idtr" onmouseover="catchindex(this)" onmouseout="catchindex(this)">
<td id="idtd">
3
</td>
</tr>
<tr>
<td>
<div id="iddiv" style="display:none">this is div3</div>
</td>
</tr>
</table></body></html>