can you show some example html by chance? Looks as thought it could definitely be simplified but seeing the html would help. ( are all of the links int eh same container by chance? if they are this could get really easy)

03-27-2013, 04:12 PM

turpentyne

Sure... here's the div that contains the <ul> list of navigation items.

The only thing I'm worried about is other javascript that I've been fighting with. I'm paranoid of screwing up any unforeseen function. a lot of the code isn't mine.

side note: I can imagine this design is pretty tough to work with. it looks like they didn't give much though to using classes vs. id in any specific manner and it's weird that they bothered assigning classes at all because they appear to be relying heavily on inline css ( cringe!! )

note- i removed the preventdefault because you didnt have anything similar in your code. if there is other js/jQ script ion the code that is applied to these elements you may want to make your changes there in the first place as doing it like this will just make the site more and more difficult to maintain.

03-27-2013, 05:34 PM

turpentyne

dang! I thought I was slick when I found a shorter option, and was about to post it here, but you found even better!

I came up with this, but still not as simple as yours.

Code:

// add class to clicked nav item, remove class from all other nav items - this switches the background image of the div