js浏览器兼容问题,只有ie正常,其他浏览器都会出现问题,请高手帮我改一下,很急,在线等
这是部分代码,如果可以帮我改,请联系加Q,大恩不言谢!function_$(target){if(!document.getElementsByClassName){do...
这是部分代码,如果可以帮我改,请联系加Q,大恩不言谢!
function _$(target){
if(!document.getElementsByClassName){
document.getElementsByClassName=function(className){
var children = 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;
}
return document.getElementsByClassName(target);
}else{
return document.getElementsByClassName(target);
}
} 展开
function _$(target){
if(!document.getElementsByClassName){
document.getElementsByClassName=function(className){
var children = 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;
}
return document.getElementsByClassName(target);
}else{
return document.getElementsByClassName(target);
}
} 展开
1个回答
展开全部
这段代码除了大小写可能会有点问题,其它应该没问题
function _$(target) {
if (!document.getElementsByClassName) {
document.getElementsByClassName = function (className) {
var children = 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].toUpperCase() == className.toUpperCase()) {
elements.push(child);
break;
}
}
}
return elements;
}
return document.getElementsByClassName(target);
}
else {
return document.getElementsByClassName(target);
}
}
function _$(target) {
if (!document.getElementsByClassName) {
document.getElementsByClassName = function (className) {
var children = 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].toUpperCase() == className.toUpperCase()) {
elements.push(child);
break;
}
}
}
return elements;
}
return document.getElementsByClassName(target);
}
else {
return document.getElementsByClassName(target);
}
}
更多追问追答
追问
能否加个Q,这些是部分代码
追答
嗯,你的QQ多少?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询