function getElementsByClassName(node, className) { if (node.getElementsByClassName) { // 使用现有方法 return node.getElementsByClassName(className); } else { // 循环遍历所有标签,返回带有相应类名的元素 var results = [], elems = node.getElementsByTagName("*"); for (var i = 0, len = elems.length; i < len; i++) { if (elems[i].className.indexOf(className) != -1) { results[results.length] = elems[i]; } } return results; } }
原文地址:https://www.cnblogs.com/qianphong/p/10449598.html
时间: 2024-12-23 00:15:41