Skip to content

Instantly share code, notes, and snippets.

@jtulk
Created August 21, 2014 01:45
Show Gist options
  • Save jtulk/f8fc762421835c2aea83 to your computer and use it in GitHub Desktop.
Save jtulk/f8fc762421835c2aea83 to your computer and use it in GitHub Desktop.
Attach .active to <a> tags in #main nav
activeMenuStyles = ->
loc = "/" + window.location.pathname.split("/")[1]
style = (link) ->
href = $(link).attr('href')
if href == loc
$(link).addClass('active')
menuLinks = $('#main > a')
style link for link in menuLinks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment