如何有效地解决ie7,IE8不支持document.getElmentsByClassName的问题

1、复制此代码到你js代码的最前面即可
 
if(!document.getElementsByClassName){
document.getElementsByClassName = function(className, element){
var children = (element || document).getElementsByTagName('*');
var elements = new Array();
for (var i=0; i
var child = children[i];
var classNames = child.className.split(' ');
for (var j=0; j
if (classNames[j] == className){ 
elements.push(child);
break;
}
}
return elements;
};
}

转载于:https://www.cnblogs.com/luoguixin/p/6240945.html

你可能感兴趣的:(如何有效地解决ie7,IE8不支持document.getElmentsByClassName的问题)