怎样通过name属性获取元素节点集合

使用 document.getElementsByName();

document.getElementsByName("userInfo") instanceof NodeList; 
// true

注意: 

1. 这个方法只对具有name属性的元素有效, 比如 <form> / <radio> / <frame> 等;

2. 返回的是一个NodeList实例对象, 而非HTMLCollection;

原文地址:https://www.cnblogs.com/aisowe/p/11543448.html