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

使用 document.getElementsByName();

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

 

注意: 

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

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

posted on 2019-09-18 16:41  aisowe  阅读(666)  评论(0编辑  收藏  举报

导航