#107: Building Snippets Area, Part 4 (JavaScript)

(Updated on )

With the design for the snippets area “done” – we can now move into some interactivity (read: JavaScript).

We add a super lame rollover for the links on the left just so we have something, but we know we’ll change that later. Then we set about actually writing some JavaScript. Upon visiting the page for the first time, the first category (HTML) will be active. Active, meaning it has the class “active” on the list item for HTML. CSS affects that class, giving it a z-index value, which visually rises the link above the shadow and connects it to the solid color line separating the two columns.

The trick is going to be when you click a different category, to remove the active class on the currently active category and apply it to the newly clicked one. It’s pretty trivial really, just a few lines of jQuery in a script that we load only on this page. Also then, the list of snippets in the right column needs to show the correct set of links, which again is just some class changing and simple show/hide manipulation.

All that’s left now is styling up the pages for individual snippets.