Smooth scrolling effect - how to target only a particular anchor point e.g. #footer_anchor?
Hello, I hope someone is good enough to help me...
I am using the the following code to smoothly scroll to the footer section of my website:
- <script type="text/javascript">
//Anonymous function that is applied to all internal-links
var jump=function(e)
{
//prevent the "normal" behaviour which would be a "hard" jump
e.preventDefault();
//Get the target
var target = $(this).attr("href");
//perform animated scrolling
$('html,body').animate(
{
//get top-position of target-element and set it as scroll target
scrollTop: $(target).offset().top
//scrolldelay: 2 seconds
},2000,function()
{
//attach the hash (#jumptarget) to the pageurl
location.hash = target;
});
}
$(document).ready(function()
{
$('a[href*=#]').bind("click", jump);
return false;
});
</script>
However, I only want this smooth scrolling action to apply to a specific anchor point (not all anchor points).
For example, my link to the footer is:
- <a href="#footer_anchor">home</a>
How do I modify the JS so that the effect is only applied to the '#footer_anchor'? If easier, I would also be happy it to anchors within a certain <DIV> e.g. only anchors within <div id="footer">
Any help greatly appreciated.