Bdrdpznhwvolx
New Member
What I want to do is have a slider where DIVs move left & right. The code looks as follows:\[code\]<script type="text/javascript">var $slider;var $transition_time = 1000; // 1 secondvar $time_between_slides = 4000; // 4 seconds $(function() { $slider = $('.slidemid'); $slider.fadeOut(); // set active classes $slider.first().addClass('active'); $slider.first().fadeIn($transition_time).css('display', 'inline-block'); // auto scroll setInterval(function () { slideright(); }, $transition_time + $time_between_slides ); $('.slidelefta').click(function() {slideleft(); return false;}); $('.sliderighta').click(function() {slideright(); return false;}); }); function slideright() { $slider = $('.slidemid'); var $i = $slider.find('.active').index(); $slider.eq($i).removeClass('active'); $slider.eq($i).fadeOut($transition_time); if ($slider.length == $i + 1) $i = -1; // loop to start $slider.eq($i + 1).fadeIn($transition_time).css('display', 'inline-block'); $slider.eq($i + 1).addClass('active');}function slideleft() { $slider = $('.slidemid'); var $i = $slider.find('.active').index(); $slider.eq($i).removeClass('active'); $slider.eq($i).fadeOut($transition_time); if ($i == 0) $i = $slider.length; // loop to end $slider.eq($i - 1).fadeIn($transition_time).css('display', 'inline-block'); $slider.eq($i - 1).addClass('active');}</script>\[/code\]The initial \[code\]fadeOut\[/code\], \[code\]fadeIn\[/code\] and \[code\]addClass\[/code\] (in the \[code\]document.ready\[/code\] function) get executed just fine.The calls to \[code\]slideright()\[/code\] and \[code\]slideleft()\[/code\] never get executed though.