Reputation: 267049
How can I send a user to a url where it will automatically scroll to a given <li>
?
E.g mysite.com/something.html#someItem
have him scroll to
<ul>
<li id='someItem'>Something here</li>
</ul>
Upvotes: 2
Views: 433
Reputation: 10104
You need an anchor tag. Like this:
<ul>
<li id='someItem'>
<a name='someItem'></a>
Something here
</li>
</ul>
Edit: markup
Upvotes: 0
Reputation: 7011
There's plenty of examples of scrolling to (any) element using jQuery. There's even plugins that'll do it for you, like ScrollTo. :-)
If you want a (really) simple example, here it is:
function scrollTo(selector) {
$('html, body').stop().animate({
scrollTop: $(selector).offset().top
}, 1000,'easeInOut');
}
Upvotes: 1