Courtney Whiting
asked on
Javascript Carousel
I am trying to create a auto-rotating carousel that performs several events with each change. I thought that I might be on the right track with where I am now but it isn't working. Any ideas? Thanks!
function changeSlide1() {
document.querySelector('#carousel-img').src = "images/slide1.jpg";
document.querySelector('#description').style.visibility = "visible";
document.querySelector('#img-1').style.opacity = "1";
document.querySelector('#img-2').style.opacity = "0.3";
document.querySelector('#img-3').style.opacity = "0.3";
}
function changeSlide2() {
document.querySelector('#carousel-img').src = "images/slide-2.jpg";
document.querySelector('#description').style.visibility = "hidden";
document.querySelector('#img-2').style.opacity = "1";
document.querySelector('#img-1').style.opacity = "0.3";
document.querySelector('#img-3').style.opacity = "0.3";
}
function changeSlide3() {
document.querySelector('#carousel-img').src = "images/slide-3.jpg";
document.querySelector('#description').style.visibility = "hidden";
document.querySelector('#img-3').style.opacity = "1";
document.querySelector('#img-1').style.opacity = "0.3";
document.querySelector('#img-2').style.opacity = "0.3";
}
var changeArray = [
changeSlide1,
changeSlide2,
changeSlide3
];
var count = 1;
window.setInterval(function() {
changeArray[count];
count++
if (count > 2) {
count = 0;
}
}, 4000)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are most welcome Courtney.
ASKER
Thank you so much though Julian for helping out with that late night project!! You really came through when I just couldn't find the information I was looking for elsewhere.