javascript - onclick won't scroll the body -
i need keep onclick reason can't make want. want slide body next logo if previous logo clicked.
it looks this:
<div class="logos"> <div class="logo" id="logo1"><a href="javascript:// something" onclick="slide()"><img src="..."></a></div> <div class="logo" id="logo2"><a href="javascript:// something" onclick="slide()"><img src="..."></a></div> <div class="logo" id="logo3"><a href="javascript:// something" onclick="slide()"><img src="..."></a></div> </div>
and then:
function slide() { var ind = $(this).closest('.logo').index(); var $logos = $('.logo'); var $next = $logos.eq(++ind); var timer_slide = window.settimeout(start_slide, 300); function start_slide() { if ($next.length) { var = $next.offset().top; } else { var = $logos.filter(":first").offset().top; } $('body, html').animate({ scrolltop: }) } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if way works:
<div class="logos"> <div class="logo" id="logo1"><a href="javascript:// something"><img src="..."></a></div> <div class="logo" id="logo2"><a href="javascript:// something"><img src="..."></a></div> <div class="logo" id="logo3"><a href="javascript:// something"><img src="..."></a></div> </div> $("#logo1").click(function(){ var ind = $(this).closest('.logo').index(); var $logos = $('.logo'); var $next = $logos.eq(++ind); var timer_slide = window.settimeout(start_slide, 300); function start_slide() { if ($next.length) { var = $next.offset().top; } else { var = $logos.filter(":first").offset().top; } $('body, html').animate({ scrolltop: }) } });
the reason can't use 1 works because controlled main html , other external buttons done onclick="..." , works far except this.
i'd appreciate if has idea how make onclick works slider.
thanks lot.
worked answer..
here's url of codes: http://fiddle.jshell.net/zepyp/
onclick on first image autoscrolls animatedly first logo, onclick on second image autoscrolls animatedly second logo , third image.
Comments
Post a Comment