我发现getElementsByName有些控件不支持,如 ,这是为什么?

oceanmeng oceanmeng 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我发现getElementsByName有些控件不支持,如<br><img> ,这是为什么?
document.getElementsByName('setBr').length
document.getElementsByName('setpImg' ).length


<br id='setpBr1' name='setBr'>
<br id='setpBr2' name='setBr'>
<br id='setpBr3' name='setBr'>
<br id='setpBr4' name='setBr'>
<br id='setpBr5' name='setBr'>


<img id='setpImg1' name='setpImg' src='./img/going_down.png' height='59' width='36'/>
<img id='setpImg2' name='setpImg' src='./img/going_down.png' height='59' width='36'/>
<img id='setpImg3' name='setpImg' src='./img/going_down.png' height='59' width='36'/>
<img id='setpImg4' name='setpImg' src='./img/going_down.png' height='59' width='36'/>
<img id='setpImg5' name='setpImg' src='./img/going_down.png' height='59' width='36'/>
...全文

相关推荐

Document:getElementsByName()使用方法及示例

Document:getElementsByName()想必大家对它并不陌生吧,主要是根据名称获取元素,下面是其具体的使用方法及范例,感兴趣的朋友不要错过

weixin_38674569

解决 firefox 不支持 document.all的方法

解决 firefox 不支持 document.all的方法

weixin_38663973

Javascript访问html页面的控件的方法详细分析第1/2页

下面切入正题:    访问控件的主要对象是:document对象。分别对应当前文档所有的(子对象)个人观点。并且已经提供的几个主要方法来访问对象。 1.       document.getElementById 2.       document.getElementsByName  3           document.getElementsByTagName 4           document.all 下面我主要谈谈以上几个方法的具体用法:   一.首先我来谈谈document.getElementById的用法。 Var obj=document.getElementById

weixin_38716081

document.all与getElementById、getElementsByName、getElementsByTagName用法区别-document.all第1/2页

Document.all[]是文档中所有标签组成的一个数组变量,包括了文档对象中所有元素

weixin_38661236

innerHTML 和 getElementsByName 在IE下面的bug 的解决

比如有这样一个问题。 代码如下: <div id=”playlist”> </div> 在这div 中,加入一个播放吗列表。这列表用innerHTML 加入。 代码如下: var plst = null; plst = player.getPlaylist(); if (plst) { var txt = ”; for(var i in plst) { txt += ‘<a></a><div class=”fv_item” id=”fv_item_’+>&lt;div class=”playing_bg” name=”playi

weixin_38674115
评论 6
收藏 已收藏
分享
返回顶部
oceanmeng
JavaScript 87,983 成员 224,681 内容