Book Image

jQuery for Designers Beginner's Guide Second Edition

By : Natalie Maclees
Book Image

jQuery for Designers Beginner's Guide Second Edition

By: Natalie Maclees

Overview of this book

Table of Contents (21 chapters)
jQuery for Designers Beginner's Guide Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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 id="dotnav"></ul>');
    $('body').append(dotnav);

    We're selecting the <body> element of the document and appending our navigation to the end of the body using jQuery's append() method.

  3. Next, we need to fill the navigation with...