I wish to create a jQuery slider (and hold off on marking this as duplicate just yet) with the code below.
<div class="jumbotron">
<div class="top">
<div class="arrow-next">Next</div>
<div class="arrow-prev">Prev</div>
</div>
<div class="bottom">
<div class="row">
<div class="col-md-4 info-box"></div>
<div class="col-md-4 info-box"></div>
<div class="col-md-4 info-box"></div>
</div>
</div>
</div>
.jumbotron {
margin: 0; padding: 0;
position: relative;
}
.jumbotron .bottom {
position: absolute; bottom: 0; left: 0; right: 0; height: 30%;
background-color: lightseagreen; padding: 0;
}
.jumbotron .bottom .row {
position: absolute; top: 0; bottom: 0; right: 0; left: 0;
}
.jumbotron .bottom .info-box {
position: relative; margin: 0;
}
.jumbotron .top {
position: absolute; top: 0; left: 0; right: 0; height: 70%;
background-color: darkgrey;
}
.jumbotron .bottom .info-box:first-child:after {
content: "";
position: absolute; top: -14px; left: 48%; right: 48%;
border: 15px lightseagreen solid; border-top: none; border-left: 15px transparent solid; border-right: 15px transparent solid;
}
.jumbotron .info-box {
border-right: 1px white solid;
min-height: 100%;
}
.arrow-next, .arrow-prev {
position: absolute; bottom: 0; top: 0; right: 0; width: 50px; vertical-align: middle; text-align: center;
background-color: rgba(54,54,54,0.6); z-index: 999; color: white; display: none;
}
.arrow-prev {
position: absolute; left: 0; bottom: 0; top: 0; right: none;
}
$('.jumbotron').css("height",$(window).height()-$('.navbar').height());
$('.top').mouseenter(function() {
$('.arrow-next, .arrow-prev').fadeIn(1000);
});
$('.top').mouseleave(function() {
$('.arrow-next, .arrow-prev').fadeOut(1000);
});
$('.arrow-next').click(function() {
var currentSlide = $('.info-box:after');
var nextSlide = currentSlide.next();
if(nextSlide.length === 0) {
nextSlide = $('.info-box').first();
}
currentSlide.fadeOut(600).removeClass('.info-box:after');
nextSlide.fadeIn(600).addClass('info-box:after');
});
My problem is my jQuery, which I can't seem to get to work. What I wish for is to move the pseduo class after from the first to second to third (and back to the first) child of the info-boxes when arrow-next is clicked (and arrow-prev for the opposite). I'm unsure as to whether you can move pseudo elements with jQuery, as the triangular effect I'm looking for with the :after element is more difficult to achieve with non-pseudo elements.
Thank you in advance. Here is a jsfiddle.
Edit: My question is different from the supposed duplicate as I am wishing to actually amend properties of the element, not the content. That supposed duplicate does not explain that in the least.