Creating a dynamic table of contents
A table of contents is a common way to allow users to quickly get to the section of content they are looking for. With jQuery, it is possible to create a table of contents dynamically, based on the HTML header elements on the page. This is very useful for blog posts or other sites that have lots of different content pages.
recipe-5.js as before and have all three open and ready for editing.
How to do it…
With the required files created, perform the following steps to create a dynamic table of contents:
- Create a basic web page using the following HTML code, adding it to
<!DOCTYPE html> <html> <head> <title>Chapter 6 :: Recipe 5</title> <link href="recipe-5.css" ...