javascript - Animate -> Slide to left not working jQuery -


i have div: "id1" , want slide "id2"

i have button on <div id="id1"> has:

<a href="#id2">next</a> 

and have script:

$(function() {     $('#next-button2').bind('click',function(event){         var $anchor = $(this);          $('html, body').stop().animate({             scrollleft: $($anchor.attr('href')).offset().left         }, 2000);          event.preventdefault();     }); }); 

that took this site, not working, ideas why?

your script looking bind animation function dom object id = next-button2

change html to:

<a id="next-button2" href="#id2">next</a> 

so jquery can bind click function right dom object.

also, you'll need make actual animation bind correct object, change:

$('html, body') 

to:

$('#id1') 

if want more in depth answer may want provide more html, js / jq, , css at.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -