相同name的input 判断点击的是第几个,找下标
2015-08-03 17:54
405 查看
<html>
<script>
function a(thisa)
{
var len=document.getElementsByName("a");
for(var i=0;i<len.length;i++){
if(len[i]==thisa){
alert(i);
}
}
}
</script>
<body>
<input type="text" name="a" value="a" onclick="a(this)"/><br>
<input type="text" name="a" value="b" onclick="a(this)"/><br>
<input type="text" name="a" value="c" onclick="a(this)"/><br>
</body>
</html>
<script>
function a(thisa)
{
var len=document.getElementsByName("a");
for(var i=0;i<len.length;i++){
if(len[i]==thisa){
alert(i);
}
}
}
</script>
<body>
<input type="text" name="a" value="a" onclick="a(this)"/><br>
<input type="text" name="a" value="b" onclick="a(this)"/><br>
<input type="text" name="a" value="c" onclick="a(this)"/><br>
</body>
</html>
相关文章推荐
- ToughRADIUS在windows下的安装配置
- http://blog.sina.com.cn/s/blog_5fde608901010pl5.html
- AAA学习笔记
- authentication password与scheme区别
- AAA-本地认证篇
- Poj_1088_滑雪(DP)
- Poj 1006 生理周期(中国剩余定理)
- Poj1012_Joseph
- Poj1258_Agri-Net(最小生成树)
- Poj 1061 青蛙的约会(扩展欧几里得解线性同余式)
- Poj1159 Palindrome(动态规划DP求最大公共子序列LCS)
- Poj 1017 Packets(贪心策略)
- poj 1273 Drainage Ditches(最大流,E-K算法)
- Poj1062 昂贵的聘礼 (dijkstra算法)
- 最长递增子序列(LIS)
- Poj 3903 Stock Exchange(LIS)
- tac_plus安装和配置