You can use the $.mobile.silentScroll
method to scroll to any vertical position on your page, without triggering the scroll event listeners. This recipe shows you how to use silent scrolling.
Copy the full code of this recipe from the code/09/silentscroll
source folder. You can launch this code by using the URL: http://localhost:8080/09/silentscroll/main.html
.
Create
main.html
with an emptydiv
tag and two buttons that will be used to scroll to the top and bottom of the page:<div data-role="content"> <button id="bottombtn">Page Bottom</button> <div id="dispdiv"></div> <button id="topbtn">Page Top</button> </div>
Add the following script to the
<head>
section to create a lengthy page:$("#main").live("pageinit", function(event) { var str=""; for (var i=0; i<100; i++) { str += i + "<br/>"; } $("#dispdiv").html(str);
Now, based on the button clicked, scroll to the top...