Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bxSlider Custom pre next Button

I want to use my own pre and next buttons and it is out of the slider div too. I am using BxSlider. I will share my code a bit. I will be glad if you can help this out.

This is the buttons and slides.

  <div class= "productsbuttons"><img id ="proprev" src="images/productleftarrow.png" /><img style="margin-left:10px;" id="pronext" src="images/productrightarrow.png" /> </div>
            </div>       
            <div class = "products">
              <ul class = "mainslider">
                <li><img class = "productslider" src="images/menu-image/img1.png" /> Lores ASda</li>
                <li><img class = "productslider" src="images/img1.png" /> ASDasdasd</li>
                <li><img class = "productslider" src="images/menu-image/img1.png" /> ASd</li>
                <li><img class = "productslider" src="images/img1.png" /> ASas</li>
              </ul>

This is the jquery

$(document).ready(function() {
  var mySlider =   $('.mainslider').bxSlider({
  nextSelector: '#pronext',
  prevSelector: '#proprev',

  prevText: '',   
  nextText: '',
  minSlides: 2,
  maxSlides: 2,
  slideWidth: 360,
  slideMargin: 5,
  pager:false,
    });
  });
like image 897
Berke Atmaca Avatar asked Nov 26 '22 23:11

Berke Atmaca


2 Answers

Add your image src to nextText like this:

nextText: '<img src="images/next.jpg" height="25" width="25"/>',
prevText: '<img src="images/previous.jpg" height="25" width="25"/>'

Working JSFiddle of an working example:

like image 154
dhruv1000 Avatar answered Dec 04 '22 10:12

dhruv1000


you can try this code below. This should work.

$(document).ready(function(){

    var slider = $('.mainslider').bxSlider({
        minSlides: 2,
            maxSlides: 2,
            slideWidth: 360,
            slideMargin: 5,
            pager:false,
    });

    $('#pronext').click(function(){
      slider.goToNextSlide();
      return false;
    });

    $('#proprev').click(function(){
      slider.goToPrevSlide();
      return false;
    });

});
like image 45
qsmiley86 Avatar answered Dec 04 '22 10:12

qsmiley86