Your test:
$datahide = $('.why-uk2-nav').hasClass( $datashow );
return a boolean, true
/ false
and not any class name.
This should work:
$('.why-uk2-slider').bxSlider({
pagerCustom: '.why-uk2-nav',
mode: 'vertical',
controls: true,
slideMargin: 100,
easing: 'easeInOutQuart',
speed: 850,
last : "first", // Save last class
onSlideBefore: function (
currentSlideNumber,
totalSlideQty,
currentSlideHtmlObject) {
var $datashow = $('.why-uk2-slider article')
.eq(currentSlideHtmlObject+1)
.attr('data-show');
// Open your console to view this, remove it when OK.
console.log("REMOVE: " + this.last,
"ADD : " + $datashow,
"class : " + $('.why-uk2-nav').attr("class")
);
$('.why-uk2-nav').removeClass(this.last).addClass($datashow);
this.last = $datashow; // Save current as last for next time.
}
});
And add this to your HTML:
<nav class="why-uk2-nav first">
|
+------ class of first
In effect in your original code you will end up with never removing a class. After you have looped trough all slides the why-uk2-nav
will have:
className = "why-uk2-nav first second third fourth"