①document.getElementById有时会抓name放过了id,据说是IE的一个BUG;
http://community.csdn.net/Expert/topic/4223/4223888.xml?temp=.1947443
页面中有
程序代码
<inputtype="hidden"id="hello8"name="category_id"value="2"/>
<selectid="category_id"onchange="al();">
一个是name="category_id"一个是id="category_id"
用document.getElementById取第二个,可是,取到的却是第一个name=category_id
在IE中getElementById竟然不是先抓id而是先找name相同的物件...
兩個form,每個form有兩個textbox,兩個form中的textbox是相同的name,但id都不同...
這樣在Firefox是沒問題的...但在IE卻只抓得到第一個出現的name資料
下面这段代码可以验证这个结果
getElementById
【document.getElementById的一些细节】相关文章:
★ js设置document.domain实现跨域的注意点分析
★ document 和 document.all 分别什么时候用
★ javascript+HTML5自定义元素播放焦点图动画
★ javascript实现点击商品列表checkbox实时统计金额的方法
★ document.all还是document.getElementsByName?
★ document对象execCommand的command参数介绍