我在两个不同的页面中有一个滑块,两个滑块的js代码都写在一个js文件中问题是第二个javascript取消了第一个javascript的功能这里是我如何写它...
var mySubhome = 0;
function caballo() {
var j;
var z = document.getElementsByClassName("mySlydesProduct");
console.log(z)
for (j = 0; j < z.length; j++) {
z[j].style.display = "none"
}
mySubhome++;
if (mySubhome > z.length) {mySubhome = 1}
z[mySubhome-1].style.display = "block";
setTimeout(caballo, 2500);
}
window.onload = function(){
caballo();
}
var myIndex = 0;
function carusel() {
var i;
var x = document.getElementsByClassName("mySlydesHome");
console.log(x)
for (i = 0; i < x.length; i++) {
x[i].style.display = "none"
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carusel, 1900);
}