Created
September 16, 2021 06:45
-
-
Save xlawok/b1d72ead578f1fa7a46057721b0e33bd to your computer and use it in GitHub Desktop.
jQuery plain slider - img only sliding - header is still
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arrow_wrapper=$('.arrow-wrapper'); | |
if($(arrow_wrapper)){ | |
var prev=$('.arrow-wrapper .prev'); | |
var next=$('.arrow-wrapper .next'); | |
var banner_imgs = $('.banner-img-wrapper .banner-img-cnt'); | |
var banner_img_length = $(banner_imgs).length; | |
console.log(banner_img_length); | |
$(next).click(function(e) { | |
e.preventDefault(); | |
let active_img=$('.banner-img-wrapper .banner-img-cnt.active').index(); | |
console.log(active_img); | |
if(active_img==banner_img_length-1){ | |
$(banner_imgs[active_img]).removeClass('active'); | |
$(banner_imgs[0]).addClass('active'); | |
} | |
else{ | |
$(banner_imgs[active_img]).removeClass('active'); | |
$(banner_imgs[active_img+1]).addClass('active'); | |
} | |
}); | |
$(prev).click(function(e) { | |
e.preventDefault(); | |
let active_img=$('.banner-img-wrapper .banner-img-cnt.active').index(); | |
console.log(active_img); | |
if(active_img==0){ | |
$(banner_imgs[active_img]).removeClass('active'); | |
$(banner_imgs[1]).addClass('active'); | |
} | |
else{ | |
$(banner_imgs[active_img]).removeClass('active'); | |
$(banner_imgs[active_img-1]).addClass('active'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment