我想拿到下拉框中所有的name,也就是一个页面有多少个select就拿到多少的select <select id=""><option>list</option></select> 我想拿到下拉框中所有的name,也就是一个页面有多少个select就拿到多少的select <select id=""><option>list</option></select> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 什么意思?document.getElementsByTagName("SELECT")? function GetName() { var arrList = document.getElementsByTagName("SELECT"); var iCount = arrList.length; for(var i=0 ; i<iCount ; i++) { arrList[i].name; ......... } } var obj_all = document.getElementsByTagName("SELECT");for(i=0;i<obj_all.length;i++){ alert(obj_all[i].name);} var obj_all = document.getElementsByTagName("SELECT"); for(i=0;i <obj_all.length;i++){ alert(obj_all[i].name); } 正解 用getElementsByTagName 获取所有 select <html> <head> <script>function init(){ var se=document.getElementsByTagName("select"); alert(se.length); for(var i=0;i<se.length;i++) { alert(se[i].id);//是id就id,是name,就写成se[i].name); }}</script></head> <body><select id="s1"><option ></option></select><select id="s2"><option ></option></select><select id="s3"><option ></option></select><select id="s4"><option ></option></select><select id="s5"><option ></option></select><input type="button" onclick="init()"></body> </html> 用js如何读取两标签数据 html如何将连接的内容作为参数传递给js函数? 小问题,js动态td设置属性 急!请兄弟帮忙!在线等! 如何动态添加一个属性? 联级下拉选择框IE5不能实现,求救。 如何在网页中加入js,在访问这个网页的时候,ie的主页就变为这个网址呢? 请问那位大侠知道用JS操作华表(Cell)文件方面的资料 大家来看看阿里巴巴网站的提供的一个功能,有几点没搞清楚 关于showModalDialog,也许对各位来说是小case,请各位帮帮忙拉 各位高手帮帮忙吧,关于js里动态取控件id 如何修改拖动和关闭层的脚本为支持firefox和chrome
document.getElementsByTagName("SELECT")
?
function GetName()
{
var arrList = document.getElementsByTagName("SELECT");
var iCount = arrList.length;
for(var i=0 ; i<iCount ; i++)
{
arrList[i].name;
.........
}
}
alert(obj_all[i].name);
}
alert(obj_all[i].name);
} 正解 用getElementsByTagName 获取所有 select
<head>
<script>
function init()
{
var se=document.getElementsByTagName("select");
alert(se.length);
for(var i=0;i<se.length;i++)
{
alert(se[i].id);//是id就id,是name,就写成se[i].name);
}
}
</script>
</head> <body>
<select id="s1">
<option ></option>
</select>
<select id="s2">
<option ></option>
</select>
<select id="s3">
<option ></option>
</select>
<select id="s4">
<option ></option>
</select>
<select id="s5">
<option ></option>
</select>
<input type="button" onclick="init()">
</body>
</html>