使用 document.getElementsByName();

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

 

注意: 

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

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-10
  • 2022-12-23
相关资源
相似解决方案