javascript - How do I animate scroll on a mobile webbrowser using jQuery? -
what wan't achieve page scroll position when button pressed. have working on browsers chrome , ie doesn't seem work on mobile browser.
this code use:
$("#programmamenu").on("click", "div", function(event){ event.preventdefault(); $('html').stop().animate({ scrolltop: $("#"+$(this).attr("rel")).position().top - 120 }, 500, 'swing'); });
the event fire, scrolling doesn't occur.
with user vohuman, answer:
apparently mobile browsers scroll body element , desktop browsers scroll html element. therefor, solution question selecting both elements 'html' , 'body' so:
$("#programmamenu").on("click", "div", function(event){ event.preventdefault(); $('html, body').stop().animate({ scrolltop: $("#"+$(this).attr("rel")).position().top - 120 }, 500, 'swing'); });
Comments
Post a Comment