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

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -