How to create simple next and prev trigger button for slider's pagination buttons?

前端 未结 5 1069
滥情空心
滥情空心 2020-12-11 12:39

I am trying to carry a class between li\'s with combine each() and eq() methods when buttons clicked. I am using same code with previo

5条回答
  •  旧巷少年郎
    2020-12-11 13:04

    You could try even this:

    $('.prev').click(function() {
        var el = $.find('li[class=active]'); 
        //check if are prev li
        if(!$(el).prev().is(':first')) $(el).removeClass('active').prev().addClass('active');
    });
    
    $('.next').click(function() {
        var el = $.find('li[class=active]'); 
        //check if are next li
        if(!$(el).next().is(':last')) $(el).removeClass('active').next().addClass('active');
    });
    

提交回复
热议问题