Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // import jquery from code.jquery.com
  2. <script src="http://code.jquery.com/jquery-1.11.1.js">
  3. </script>
  4.  
  5.  
  6.  
  7. // your code
  8. <script>
  9. jQuery(document).ready(function ($) {
  10.  
  11.   $('#checkbox').change(function(){
  12.     setInterval(function () {
  13.         moveRight();
  14.     }, 3000);
  15.   });
  16.  
  17.     var slideCount = $('#slider ul li').length;
  18.     var slideWidth = $('#slider ul li').width();
  19.     var slideHeight = $('#slider ul li').height();
  20.     var sliderUlWidth = slideCount * slideWidth;
  21.    
  22.     $('#slider').css({ width: slideWidth, height: slideHeight });
  23.    
  24.     $('#slider ul').css({ width: sliderUlWidth, marginLeft: - slideWidth });
  25.    
  26.     $('#slider ul li:last-child').prependTo('#slider ul');
  27.  
  28.     function moveLeft() {
  29.         $('#slider ul').animate({
  30.             left: + slideWidth
  31.         }, 200, function () {
  32.             $('#slider ul li:last-child').prependTo('#slider ul');
  33.             $('#slider ul').css('left', '');
  34.         });
  35.     };
  36.  
  37.     function moveRight() {
  38.         $('#slider ul').animate({
  39.             left: - slideWidth
  40.         }, 200, function () {
  41.             $('#slider ul li:first-child').appendTo('#slider ul');
  42.             $('#slider ul').css('left', '');
  43.         });
  44.     };
  45.  
  46.     $('a.control_prev').click(function () {
  47.         moveLeft();
  48.     });
  49.  
  50.     $('a.control_next').click(function () {
  51.         moveRight();
  52.     });
  53.  
  54. });    
  55.  
  56. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement