Hi I am using jQuery to create custom navigation, but I cannot determine how to detect the active slide and apply the active state to the button for this slide.
I am setting up jsfiddle to better show what I'm trying to do, basically the same function as the dots / pager in the slider, but on buttons 1 2 and 3.
Im new to jQuery .data part: P
http://jsfiddle.net/unknown601/yxErC/17/
<div class="number" id="" data-slider="0"> Button 1 </div> <div class="number" id="" data-slider="1"> Button 2 </div> <div class="number" id="" data-slider="2"> Button 3 </div> <ul class="slider"> <li data-current="1"> <img src="http://placehold.it/350x150"> <p>Slider-1</p> </li> <li data-current="2"> <img src="http://placehold.it/350x150"> <p>Slide 2</p> </li> <li data-current="3"> <img src="http://placehold.it/350x150"> <p> Slide 3</p> </li> </ul> #current { color: red; font-weight: bold; } .number:hover { color: blue; cursor: pointer; }
You have buttons to control the slider :)
var Slider; $(document).ready(function() { Slider = $('.slider').bxSlider({ pager: true }); $('.number').on('click', function(e) { e.preventDefault(); var index = $(this).attr('data-slider'); Slider.goToSlide(index); }); });
source share