8. Previous Slide 1 "Uncaught SyntaxError: Unexpected token ."


#1

I cannot find this "Unexpected Token ." anywhere! Please help :slight_smile:

var main = function() {
  $('.dropdown-toggle').click(function() {
    $('.dropdown-menu').toggle();
var currentSlide = $('.active-slide')
var prevSlide = .prev()
    $('.currentSlide').fadeOut(600).removeClass('active-slide');
    $('.prevSlide').fadeIn(600).addClass('active-slide');
});

  $('.arrow-next').click(function() {

var currentSlide = $('.active-slide');
var nextSlide = currentSlide.next();

var currentDot = $('.active-dot');
var nextDot = currentDot.next()
    
if(nextSlide.length == 0) {
    nextSlide = $('.slide').first();
    nextDot = $('.dot').first();
}    
    
  currentSlide.fadeOut(600).removeClass('active-slide');
  nextSlide.fadeIn(600).addClass('active-slide');
 
    currentDot.removeClass('active-dot');
    nextDot.addClass('active-dot');
  });
}
  $('.arrow-prev').click(function() {
var currentSlide = $('.active-slide');
var prevSlide = currentSlide.prev();

    currentSlide.fadeOut(600).removeClass('active-slide');
    prevSlide.fadeIn(600).addClass('active-slide');
    
});

$(document).ready(main);

#2

Hi @thetherington,

  1. You don't need to be messing with slides inside your $('.dropdown-toggle').click(...); part, so remove those four lines
  2. Move the closing curly brace (}) on line 30 down to just before the last line, since everything you're running needs to be inside your main function that gets run when the page has loaded.

If your code still isn't working, please post the updated code and a link to the lesson you're on :slight_smile:


#3

Hi @zystvan,

Thank you for the reply!

I am now getting the error "Oops, try again. Remember to fade out the current slide and remove the 'active-slide' class"

I have updated the code, below:

var main = function() {
  $('.dropdown-toggle').click(function() {
    $('.dropdown-menu').toggle();
var currentSlide = $('.active-slide')
var prevSlide = .prev()
    $('.currentSlide').fadeOut(600).removeClass('active-slide');
    $('.prevSlide').fadeIn(600).addClass('active-slide');
});

  $('.arrow-next').click(function() {

var currentSlide = $('.active-slide');
var nextSlide = currentSlide.next();
  
var currentDot = $('.active-dot');
var nextDot = currentDot.next()
    
if(nextSlide.length == 0) {
    nextSlide = $('.slide').first();
    nextDot = $('.dot').first();
}    
    
  currentSlide.fadeOut(600).removeClass('active-slide');
  nextSlide.fadeIn(600).addClass('active-slide');
 
    currentDot.removeClass('active-dot');
    nextDot.addClass('active-dot');
  });
}
 $('.arrow-prev').click(function() {
  var currentSlide = $('.active-slide');
  var prevSlide = currentSlide.prev();

  if(prevSlide.length == 0) {
    prevSlide = $('.slide').last();
  }

  currentSlide.fadeOut(600).removeClass('active-slide');
  prevSlide.fadeIn(600).addClass('active-slide');
});

$(document).ready(main);

#4

@thetherington You still need to remove lines 4-7, those look like they're causing the main problem.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.