How can I send a user to a url where it will automatically scroll to a give开发者_开发问答n <li>
?
E.g mysite.com/something.html#someItem
have him scroll to
<ul>
<li id='someItem'>Something here</li>
</ul>
Exactly that.
Your code will work as-is.
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');
}
You need an anchor tag. Like this:
<ul>
<li id='someItem'>
<a name='someItem'></a>
Something here
</li>
</ul>
Edit: markup
精彩评论