Interactive Website exercise Next dot 1.Next dot 2


#1

$('.arrow-prev').click(function(){$('.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');
});
$('.arrow-next').click(function(){
var currentSlide = ('.active-slide');
var nextSlide = currentSlide.next();
if(nextSlide.length == 0) {
nextSlide = $('.slide').first();
var currentSlide = $('.active-slide');$('.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');
});
$('.arrow-next').click(function(){
var currentSlide = ('.active-slide');
var nextSlide = currentSlide.next();
if(nextSlide.length == 0) {
nextSlide = $('.slide').first();
var prevSlide = currentSlide.prev();

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

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


#2

@csscoder68873,
I think it is better, if one understands the concept.

It all start's with you,
using a Browser
in which you load a HTML-file,
which we will call the HTML-Document.

This document has a minimal build of


<!DOCTYPE html>
  <html>
     <head>
          <title> </title>
     </head>
     <body>
     </body>
  </html>

The Browser =load's= this document into Memory
in a pattern that is described as
the Document Object Model
in short the DOM.
( the interpretation of the DOM is Browser & Version specific )

            html
             |
       +-----+------+
       |            |
     head          body
       |
     title

In the description of your document in DOM-talk...
you will encounter terms like:
parent children sibling descendants ascendants...

The HTML-Element has no parent
but is a parent to 2 child-Element's
the 'head'-Element
and
the 'body'-Element.

The 'head'- and 'body'-Element,
both being children to the 'html'-Element
are siblings to each-other.

The 'head'-Element is parent to the 'title'-Element...
the 'title'-Element is a child of the 'head'-Element
the 'title'-Element is also a descendant of the 'html'-Element.

The DOM has several interface's
over which you can access the data**/**information
held by the DOM.

One of the interface's is the Element-interface
you can divide the interface into
properties ( consisting of a property-key and it's associated VALUE )
and
methods ( giving you the functionality to manipulate the Elements )
https://developer.mozilla.org/en-US/docs/Web/API/Element
https://developer.mozilla.org/en-US/Learn/HTML/HTML_tags


#3

@csscoder68873,
+++++ flipboard click Eventhandler structure
Within the =main= function

var main = function() {
     //Begin of =main= FUNCTION-BODY
       //your code
     //End of =main= FUNCTION-BODY
};
$(document).ready( main );

you are placing =click= Eventhandlers,
which are attached to specific HTML-Elements by using
a jQuery-Selector.like $('.arrow-prev')

var main = function() {
     //Begin of =main= FUNCTION-BODY
        $('.arrow-prev').click();
     //End of =main= FUNCTION-BODY
};
$(document).ready( main );

Now as a so-called argument of the =click= Eventhandler
you are placing a so-called anonymous function

var main = function() {
     //Begin of =main= FUNCTION-BODY
        $('.arrow-prev').click( function() {
             //code which gets executed when =click=ed
        });
     //End of =main= FUNCTION-BODY
};
$(document).ready( main );

+++++++++++++++++++++++++++++
++ jquery length explained AND DOM pictures of flipboard
https://www.codecademy.com/forum_questions/5615308ab62548021c0000e4
+++++ flipboard the next && prev steps

s t e p s - - f o r - - n e x t S l i d e
-1
-1a create a selection of nextSlide (2 steps, capture 'active-slide, capture next() slide )'
-1b create a selection of nextDot
-2 check if selection of nextSlide is EMPTY
-2a if EMPTY change nextSlide selection to first slide
-2b and change nextDot selection to first Dot
-3 swap -active-slide- and -active-dot- class from current to next
Step3 is done by

   currentSlide.fadeOut(600).removeClass('active-slide');
   nextSlide.fadeIn(600).addClass('active-slide');
   currentDot.removeClass('active-dot');
   nextDot.addClass('active-dot');

s t e p s - - f o r - - p r e v S l i d e
-1
-1a create a selection of prevSlide
-1b create a selection of prevDot
-2 check if selection of prevSlide is EMPTY
-2a if EMPTY change prevSlide selection to last slide
-2b and change prevDot selection to last Dot
-3 swap -active-slide- and -active-dot- class from current to prev
Step3 is done by

    currentSlide.fadeOut(600).removeClass('active-slide');
    prevSlide.fadeIn(600).addClass('active-slide');
    currentDot.removeClass('active-dot');
    prevDot.addClass('active-dot');

++ the build of script ++
Now as a so-called argument of the =click= Eventhandler
you are placing a so-called anonymous function

var main = function() {
     //Begin of =main= FUNCTION-BODY
        $('.dropdown-toggle').click(function(){
              $('.dropdown-menu').toggle();
        });

        $('.arrow-next').click( function() {
             //code which gets executed when =click=ed
        });
        $('.arrow-prev').click( function() {
             //code which gets executed when =click=ed
        });
     //End of =main= FUNCTION-BODY
};
$(document).ready( main );