标签:
if(window.addEventListener){
document.write(‘<script src="js/jquery-2.1.4.min.js"><\/script>‘);
}else if(window.attachEvent){
document.write(‘<script src="js/jquery-1.8.3.min.js"><\/script>‘);
//解决ie兼容getElementByClassName
if(!document.getElementsByClassName){
document.getElementsByClassName = function(className, element){
var children = (element || document).getElementsByTagName(‘*‘);
var elements = new Array();
for (var i=0; i<children.length; i++){
var child = children[i];
var classNames = child.className.split(‘ ‘);
for (var j=0; j<classNames.length; j++){
if (classNames[j] == className){
elements.push(child);
break;
}
}
}
return elements;
};
}
//
}else{
document.write(‘<script src="js/jquery-2.1.4.min.js"><\/script>‘);
}
监听浏览器使用不同版本js并且处理ie兼容getElementByClassName
标签:
原文地址:http://www.cnblogs.com/ss977/p/5846319.html