O'Reilly logo

jQuery for Designers : Beginner's Guide - Second Edition by Natalie MacLees

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – adding navigation to sections of the page

Perform the following steps to add navigation to our weather forecast:

  1. Open up scripts.js. The first thing we want to do is create an unordered list to hold our navigation. After the animation code we wrote earlier, but still inside the document ready statement, add the following bit of code:
    var dotnav = $('<ul id="dotnav"></ul>');

    First, we create a variable, dotnav. Recall that a variable is just a container. Inside this container, we're going to create a jQuery object that holds an unordered list with the id attribute of dotnav.

  2. Now that we've got our unordered list, the next thing we'll do is add it to our document. That's easy enough, just one short line of code:
    var dotnav = $('<ul ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required