I'm new to jQuery and I'm trying to create an image slider for a website. My dreamweaver application as well as console mode in browers say I have a syntax error on line 4 (highlighted). For the life of me I don't know how to fix it. Any help is very appreciated. Thanks for taking your time to help out a novice.
// JavaScript Document
$('.slider').each(function(){
//for every slider
var $this =$(this),
//Get the current slider
var $group =$this.find('.slide-group'), //Get the slide-group (container)
var $slides =$this.find('.slide',
//jQuery object to hold all slides
var buttonarray = [],
//Create array to hold nav buttons
var currentIndex = 0,
//Index number of current slide
var timeout;
//Used to store the timer
// move() - The function to move the slides goes here (see next page)
function advance() [ {
//Sets a timer between slides
clearTimeout(timeout);
//Clear timer stored in timeout
// Start timer to run an anonymous function every 4 seconds
timeout = setTimeout(function(){
//
if (currentIndex < ($slides.length - 1)) {
//If not the last slide
move(currentIndex + 1);
//Move to next slide
} else {
//Otherwise
move(0);
//Move to the first slide
}
}, 4000);
//Milliseconds timer will wait
}
$.each($slides, function(index){
// Create a button element for the button
var $button = $('<button type="button" class="slide-btn">•</button>');
if (index === currentIndex) {
// If index is the current item
$button.addClass('active');
// Add the active class
}
$button.on('click', function(){
// Create event handler for the button
move(index);
// It calls the move () function
}).appendTo('.slide-buttons');
// Add to the buttons holder
buttonArray.push($button);
// Add it to the button array
});
advance();
});