且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

javascript dom getElementsByName问题?

更新时间:2023-12-05 14:57:16

谢邀~

这个getElementsByName就是document特有的方法,
并不同与题主所说的其他方法,
其他方法适用于element

而且兼容性不好.

The getElementsByName method works differently in different browsers. In IE & Opera, getElementsByName() method will also return elements that have an id attribute with the specified value. so you should be careful not to use the same string as both a name and an ID.

传送门: https://developer.mozilla.org...