views:

55

answers:

2

How can I change background images and text on navigation menu link when it’s selected

When the user clicks on one of the navigation links, the text will change color and background image will changed too. The user should stay on the same page.

It’s working in static files on my machine, but it doesn’t work when I post it online.

A: 

Consider using jQuery — Write less, do more.

// bind a click event to all the links
$('#o_nav').find('a').click(function() {
  // make sure other backgrounds are removed
  $('#o_nav').find('a').removeClass('aSelected');
  // add selected background to clicked link
  $(this).addClass('aSelected');
});
Alec
A: 

Maybe this is what You need:
http://jsfiddle.net/nVz43/1/

czerasz