image - How to go back to the first slide unsing JQuery scrollleft and scrollright -


i want make div slider using jquery, don't know how go first slide. div slider not automatic slider. manual slider. when click 'prev' , 'next' button, can move 1 div , forth. want when reach last div, when click 'next' button, want move first div, users can start again. got 11 divs , each width 240, total 2640 px, if click 'prev' button go first, takes time.

here code. $(document).ready(function() {

        $('#next').click(function(event) {             event.preventdefault();             $('.div-container').animate({scrollleft:'+=240'}, 'slow');                 });          $('#prev').click(function(event) {             event.preventdefault();             $('.div-container').animate({scrollleft:'-=240'}, 'slow');                 });      }); 

please advise me. thanks.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -