谁能帮我把document.getElementById取值换成根据class取值,必有重谢
functionSlideShow(c){vara=document.getElementById("slideContainer"),f=document.getEle...
function SlideShow(c) {
var a = document.getElementById("slideContainer"), f = document.getElementById("slidesImgs").getElementsByTagName("li"), h = document.getElementById("slideBar"), n = h.getElementsByTagName("li"), d = f.length, c = c || 3000, e = lastI = 0, j, m;
function b() {
m = setInterval(function () {
e = e + 1 >= d ? e + 1 - d : e + 1;
g()
}, c)
}
function k() {
clearInterval(m)
}
function g() {
f[lastI].style.display = "none";
n[lastI].className = "";
f[e].style.display = "block";
n[e].className = "on";
lastI = e
}
f[e].style.display = "block";
a.onmouseover = k;
a.onmouseout = b;
h.onmouseover = function (i) {
j = i ? i.target : window.event.srcElement;
if (j.nodeName === "LI") {
e = parseInt(j.innerHTML, 10) - 1;
g()
}
};
b()
}
;
谁能帮我将这个改为根据class取值 展开
var a = document.getElementById("slideContainer"), f = document.getElementById("slidesImgs").getElementsByTagName("li"), h = document.getElementById("slideBar"), n = h.getElementsByTagName("li"), d = f.length, c = c || 3000, e = lastI = 0, j, m;
function b() {
m = setInterval(function () {
e = e + 1 >= d ? e + 1 - d : e + 1;
g()
}, c)
}
function k() {
clearInterval(m)
}
function g() {
f[lastI].style.display = "none";
n[lastI].className = "";
f[e].style.display = "block";
n[e].className = "on";
lastI = e
}
f[e].style.display = "block";
a.onmouseover = k;
a.onmouseout = b;
h.onmouseover = function (i) {
j = i ? i.target : window.event.srcElement;
if (j.nodeName === "LI") {
e = parseInt(j.innerHTML, 10) - 1;
g()
}
};
b()
}
;
谁能帮我将这个改为根据class取值 展开
1个回答
展开全部
var $container = document.getElementById('container');
var $ul = $container.getElementsByTagName('ul');
// 要取的class
var className = 'col';
var ulCollection = [];
for (var i = 0; i < $ul.length; i += 1) {
var ul = $ul[i],
classList = ul.className.split(' ');
for (var j = 0; j < classList.length; j += 1) {
if (className === classList[j]) {
ulCollection.push(ul);
break;
}
}
}
console.log(ulCollection);
var $ul = $container.getElementsByTagName('ul');
// 要取的class
var className = 'col';
var ulCollection = [];
for (var i = 0; i < $ul.length; i += 1) {
var ul = $ul[i],
classList = ul.className.split(' ');
for (var j = 0; j < classList.length; j += 1) {
if (className === classList[j]) {
ulCollection.push(ul);
break;
}
}
}
console.log(ulCollection);
追问
我是一个新手,还是不明白,要是你能直接把上面贴的改好就更好了
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询