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.

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences like this:

  function example() {
    element.innerHTML = "<div>code</div>";

We have a pretty good* newsletter.