JQtouch: Scroll to anchor in list with link
Question
I allready have used to much time, figuring out (googling) how to make a butten, scroll down to a specific < li > in a edgetoedge list. I use JQtouch with Zepto and PhoneGap (Cordova) .
Here's my very simple example, where im trying to use html anchors. It'll not work:
<div id="ListPage">
<div> <a href="#b">jump to b</a> </div>
<div class="scroll">
<ul>
<li><a name="a" />Some text</li>
.
.
50 times li.... :)
.
.
<li><a name="b" />Some text</li>
.
.
50 times li.... :)
.
.
</ul>
</div>
</div>
I cant use ID's cause JQtouch use the id and a for page transistions..
what to do...
Solution
This might help, it works for me in a separate scenario:
var pos = $("a[name=a]").position();
$('html, body').animate( { scrollTop: pos.top }, 'slow' );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow