Time for action – using the BBQ plugin

Our first order of business is to get those back and forward buttons working, and allow our site visitors to bookmark and share links to individual pages. That's why we've included the jQuery BBQ plugin.

  1. We're going to write some new JavaScript, so erase the code we wrote earlier in scripts.js and replace it with a simple document ready statement as follows:
    $(document).ready(function(){
      // Our deluxe ajaxy code goes here
    });
  2. Next, we're going to select each of the links in our main navigation and replace the URLs with hash links so that the browser thinks they are internal to our HTML page.
    $(document).ready(function(){
      $('#ajax-nav a').each(function(){
        $(this).attr('href', '#' + $(this).attr('href'));
     }); ...

Get jQuery for Designers Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.