I've tried to implement smooth scrolling into an index of info. I've looked at this jsFiddle http://jsfiddle.net/9SDLw/ and I cannot get it to work. Does it matter where the code is inserted into the HTML Document or something?
Here is my code:
JS (in head of document):
<script type="text/javascript">
$('a').click(function(){
$('html, body').animate({
scrollTop: $( $(this).attr('href') ).offset().top
}, 500);
return false;
});
</script>
Markup:
Link
<a href = "#G" rel = "" id="G" class="anchorLink">G</a><br />
Anchor
<a name = "G" id="G"><span class = "letters">G</span></a><br />
What am I missing here?