SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trying to create a "table of contents" script (see jsbin)

    Hi,
    I'm very new to jquery so please bear with me if my code is extremely horrible.

    I am trying to create a script that grabs all the h* tags on a page and outputs them into a list.

    My current problem is the order in which I'm able to output things in the list, take a look at the list item "h3 again - supposed to go after h4" and you'll see what I mean.

    Appreciate any help on what I can do differently to solve this.

    Thanks!

    http://jsbin.com/welcome/36639/

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    You might find a benefit from an existing jQuery plugin that creates a table of contents from the headings, such as http://projects.jga.me/toc/
    If you don't want to use the plugin directly, you may be able to learn something from the techniques that it uses.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •