Saturday, November 19, 2011

How do I make the background color of my horizontal navigation bar stay untill next click?

For example: I have a horizontal navigation bar with about 5 options. Those options remain the same when clicked, only a portion of the div below is changed so I want to change the color of one of the options stick until the next option is clicked, and when the next option is clicked I want to highlight that and remove the highlight from the previous one.





I have made the navigation bar using a %26lt;ul%26gt; list with %26lt;li%26gt; elements





Thanks!|||Set the clicked button to whatever color you want in your option 1's file, do the same to the rest of your 4 options files.





Either this or use jQuery's click event. Here's a link for a tutorial:





http://w3schools.com/jquery/event_click.鈥?/a>





It should be something like:





$(document).ready(function() {


----$('#navMenuBars').click(function() {


--------$('#option1').css('background-鈥?'yellow');


----});


});








Hope this helps :)

No comments:

Post a Comment