Create an Anchor Menu from Heading Tags with jQuery
You can see on the right side menu that there is a new navigation menu that allows you to jump trough each heading of this article (if it were longer) ... This is the jQuery version which I ended up not using. I decided I liked automating the anchor menu with PHP because it is SEO friendly and more efficient loading in the users browser. But this version maybe useful to some of you.
The Problem with Automating the Anchor Menu with jQuery
The main issue I had with the jQuery version is that it can be tough on the browser looping through lots of H3 tags. Also it's not very SEO friendly if that's something that is important to you then I would go with automating the anchor menu with PHP.
The Solution to Creating an Automated Anchor Menu in jQuery
The process starts after the page finishes loading:
- Find all the H3 tags and store the text between each tag.
- Format the H3 title text so it can be used as an ID anchor tag & in the URL
- Add the new ID attribute to the current H3 tag
- Append the URL navigation to the UL list.
Add New Comment