[Pro] CSS Menu click reset /current page

Here is a quick javascript example (jQuery) - http://www.deltadesign.co/FW7Test/class-on-click.html

This uses some js to add a class on clicking the link (removing it from another link if it was already applied)

But as i said this will depend on how your Menu is set up. This example is really for a single page.

You may not wish to use jQuery - the same effect can be achieved in vanilla javascript.

The Code

<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type='text/javascript'>//<![CDATA[
$('ul.class-applied-to-menu li a').click(

function(e) {
    e.stopPropagation; // stop the click from bubbling
    $(this).closest('ul').find('.selected').removeClass('selected');
    $(this).parent().addClass('selected');

});
</script>

The class that is added to each link (onclick) in my example is .selected and you can style that how you like - however you should note that any menu styling (click, hover, active etc.) will likely take precedence so best left off until you have it working as you want.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at: