daily pastebin goal
92%
SHARE
TWEET

Simple Next/Prev button Jquery logic for slider

mikele027 Jan 12th, 2018 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Implemented a simple next/prev button on a slider on product page which did not have this function implemented in default. A lot of changes needs to be made to the below jquery, just posting this for logic. This has been applied to a client’s website here : https://popular-poison.com/collections/bryce-collection/products/mm6063ss-marilyn-bandana-tee
  2.  
  3. <script>
  4.   $(function(){
  5.     $('#hc-prev').click(function(e){
  6.       e.preventDefault();
  7.          var list = $('article .thumbs ul li');
  8.       var i = list.index($('article .thumb.active'));
  9.       $(list[i-1]).trigger('click');
  10.     });
  11.     $('#hc-next').click(function(e){
  12.       e.preventDefault();
  13.          var list = $('article .thumbs ul li');
  14.       var i = list.index($('article .thumb.active'));
  15.       $(list[i+1]).trigger('click');
  16.     });
  17.   });
  18. </script>
RAW Paste Data
Top