I've created a long horizontal page and using anchors to navigate to section's within the page. I added a jQuery smooth scrolling function but it's not taking affect?
Here's the navigation:
<ul class="nav">
<li><a href="#starters">Starters</a></li>
<li><a href="#main">Main Dishes</a></li>
<li><a href="#special">Special Dishes</a></li>
<li><a href="#side">Side Dishes</a></li>
</ul>
Within the content i've added corresponding anchors:
<a name="starters"></a>
And here's the jQuery function:
$(function() {
$('ul.nav a').bind('click',function(event){
var $anchor = $(this);
$('html, body').stop().animate({
scrollLeft: $($anchor.attr('href')).offset().left
}, 1500, "easeInOutExpo");
event.preventDefault();
});
});
The anchor's work fine, clicking the navigation takes you to the desired section but it jumps instead of scrolling.
Any ideas why??