Blogger Information
Blog 16
fans 0
comment 0
visits 9621
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
通过类名获取所有元素的方法
坨坨
Original
712 people have browsed it
  1. <html>
  2. <head>
  3. <title>Title</title>
  4. </head>
  5. <body>
  6. <script>
  7. //通过类名获取所有元素的方法
  8. function gclass(className, tagName) {
  9. var alltags = document.getElementsByTagName(tagName || "*");
  10. var arr=new Array();
  11. for(let i=0; i<alltags.length; i++) {
  12. var one = className.split(" ");
  13. var two = alltags[i].className.split(" ");
  14. if(isHasArray(one, two)) {
  15. arr[arr.length] = alltags[i];
  16. }
  17. }
  18. return arr;
  19. }
  20. </script>
  21. </body>
  22. </html>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post