var len = document.forms[0].elements.length;
for(var i=0;i<len;i++){
alert(i);
}
for(var i=0;i<len;i++){
alert(i);
}
解决方案 »
- JS正则匹配()以及()中的内容
- 有extjs的datetime控件吗。3.0好像没有包含啊。
- 先执行js再打开链接的问题?
- out of memory 问题
- 关于innerHTML问题
- js问题,iframe子页面调用父页面中onload中的方法问题
- 请问如何在javascript中访问TD中的ID,急。。。。在线等!!!!!
- ▇▇▇▇▇关于javascript自定义对象问题,我错在哪了?
- 在javascript函数中怎样调用vbscript函数(返回值为一动态数组)---敬请回复!
- 判断是否包含字符串@163.net?
- (续)各位兄弟姐妹们,有没有响应鼠标事件,滚动层的JS代码啊?
- js如何把窗口整洁一下 变的象弹窗那样 其余的导航什么的都不要
var theObjs = document.forms[0].getElementsByTagName( "INPUT" );
for( i = 0 ; i < theObjs.length ; i++ )
{
if( theObjs[ i ] == theInput )
{
alert( i )
}
}
to xishanlang2001(西山狼2000):因为form里有很多的input,如果都循环的话可能会影响速度,有没有办法不做循环或者做少量循环得到input的索引号
var theObjs = document.forms[0].getElementsByTagName( "INPUT" );
for( i = 0 ; i < theObjs.length ; i++ )
theObjs[ i ].indexID = i;以后就可以用indexID得到了
一次循环总可以吧