Columbus, Ohio SEO Expert | Jacob Stoops

JQuery Scrolling Effect for Designers

Post Comments
0 Comments

JQuery Scrolling Effect for DesignersWant to learn how to do a cool JQuery Scrolling Effect on your site? It’s actually very easy to do! You can thank my good friend Eric Leslie at On Scene Media & Marketing for requesting this JQuery Scrolling Effect Tutorial.

JQuery is an awesome yet easy coding language and there are many other cool things you can do with it. I will try to show you how to implement the JQuery Scrolling Effect on your site in 5 easy steps…

You can see an example of JQuery Scrolling in action on my SEO Dictionary page…

Okay Let’s Get Into It!!!

1.) Download & Install the JQuery Library

The first thing you need to do is download the most current JQuery Library and install it in your site’s root folder.

2.) The HTML Link Anchors

In order to make this effect work, we will need to implement anchor links to that will allow us to jump to certain points on a webpage quickly. Later, JQuery will work its magic to make the transition from link to anchor look much smoother.

Regular HTML Anchor Links look like this:

<a href="#jump">Jump to Someplace</a>

The link for the spot your jumping to looks like this:

<a name="jump" href="#"></div>

Once you’ve figured out where you want to scroll to and from, implement and place your Link Anchors.

3.) The JQuery Scrolling Effect

Next place the following JQuery code into your preferred HTML Editor.

$(document).ready(function(){
$('a[href*=#jump]').click(function() {
if (location.pathname.replace(/^\//,") == this.pathname.replace(/^\//,")
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target
|| $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body')
.animate({scrollTop: targetOffset - 125}, 1000);
return false;
}
}
});
});

The only place where you will need to edit anything will be the section that I’ve bolded. All you need to do is place in your Anchor Link’s name or id. If you have more than one spot that your are using Anchor Links for, simply copy & paste the same code and replace the id name.

Once you’ve finished this step, save the file as “scrolling.js” and upload to your site’s root.

4.) Refer to the File

Now that you’ve created, saved, and hosted the JQuery Library and the JQuery Scrolling Javascript, you will need to refer to it in the <head> section of your site.

To refer to the file, place the following code in between your <head></head> tags.

<script type="text/javascript" src="/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="/scrolling.js"></script>

Keep in mind that you can name to files any way you like, just make sure to spell them correctly and use the correct files paths when you refer to them. Otherwise our newly learned JQuery Scrolling Effect will not work.

5.) Test it Out!

Now that you’ve successfully completed my JQuery Scrolling Effect tutorial, feel free to surf around your site and test out it’s cool new functionality! Also, if you have any suggestions for me regarding articles leave a comment or contact me via email.

GD Star Rating
loading...

This entry was posted in Web Design and tagged , , . Bookmark the permalink.

Jacob Stoops

About the Author

is an SEO professional living in Columbus, Ohio and working for Rosetta Marketing. He's been working in the SEO industry since 2006, and has been blogging since 2009. Learn more about , a Columbus, Ohio SEO Expert.

Comments & Social Reactions

  • http://beonscene.com Eric Leslie

    Excellent presentation and execution of this mark!

    JQuery is a fun tool, I love the way it helps make your page flow dynamic!

    GD Star Rating
    loading...
  • Pingback: JQuery: Where to begin?? «

  • John

    Dude, would really help if you put a friggen example of what it will look like somewhere so we can see it before doing the whole tutorial!

    GD Star Rating
    loading...
    • http://www.agent-seo.com/ Jacob Stoops

      Apologies. I had an example before my recent redesign. I’ll get one back in there shortly!

      GD Star Rating
      loading...
    • http://intensedebate.com/people/jacobstoops Jacob Stoops

      An example is now included in the article. Took me a while to get back to this as I was working on the re-design.

      GD Star Rating
      loading...
  • Pingback: Fresh JQuery Tutorials | Galaxark Blog

  • http://www.marble-design.co.uk Vicky

    brilliant tutorial, I was tearing my hair out trying to figure out how to do this then found you post and so simple!!
    thank you!

    GD Star Rating
    loading...
    • jacobstoops

      Glad I could help Vicky.

      GD Star Rating
      loading...
  • chris

    Great tutorial, nice and easy to follow. One question though, how do I add an extra value to the scroll destination, say for example another 40 pixels?

    I am sure its very obvious but I am new to all this so please excuse my ignorance.

    Thanks in advance

    Chris

    GD Star Rating
    loading...
    • jacobstoops

      Not sure what you mean by extra value in relation to 40 pixels, please expand a bit and I'll see if I can help?

      GD Star Rating
      loading...
    • chris

      Sorry, I wasnt very clear, basically I want to scroll to the destination but leave a gap above the content. I presume its something olong the lines of adding -40px somewhere?

      If your still unclear please view this example where each images links to the next but appears with a gap at the top.

      http://www.studiomakgill.com/disciplines/web/bl…

      Thanks

      Chris

      GD Star Rating
      loading...
      • jacobstoops

        I don't know of anything that you can write into the JQuery to do that, however you might be able to achieve this by simply scrolling to a different portion of the page via a blank link anchor…

        Something like that might work if you put it in the position that you want to scroll to? Sorry it's not a very technical answer, but I hope this helps…

        GD Star Rating
        loading...
  • chris

    OK thanks, I had considered that as an option but it didn't seem very efficient. I am approaching this from a flash background and assumed that adding or subtracting a value from the variable that we are scrolling to would do the trick but it seems not.

    Thanks again for your help and quick responses.

    Chris

    GD Star Rating
    loading...
  • Pingback: Blog  |  Arnoud Terpstra

My Work
Agent SEO Portfolio | Ohio SEO

Connect with Me

2454 Subscribers & Followers
  • Subscribe to the Agent SEO RSS Feed
  • Follow Jacob Stoops on Twitter
  • Follow Jacob Stoops on Facebook