Menu page selected and add class using jquery

Hi,

I am looking for jquery plugin or jquery script to show selected active page.

I will apply class to active element.

Following is my header menu link

<tr valign="bottom"  class="topmenu">
	<td width="317" align="left"><img src="includes/images/logo.jpg"></td>
	<td width="10%"><a href="#" class="topmenu_active">Home</a></td>
	<td width="12%"><a href="#">Tab1</a></td>
	<td width="15%"><a href="#">Tab2</a></td>
	<td width="8%"><a href="#">Tab3</a></td>
	<td width="12%"><a href="#">Tab4</a></td>
	<td width="10%">&nbsp;</td>
</tr>

I need solution using only jquery not css or any other way.

Any idea?

-Thanks

Hi,

So, you want to apply an additional class to whichever element has a class of “topmenu_active”?

E.g.

<tr valign="bottom"  class="topmenu">
	<td width="317" align="left"><img src="includes/images/logo.jpg"></td>
	<td width="10%"><a href="#" class="topmenu_active [B]MYCLASSHERE[/B]">Home</a></td>
	<td width="12%"><a href="#">Tab1</a></td>
	<td width="15%"><a href="#">Tab2</a></td>
	<td width="8%"><a href="#">Tab3</a></td>
	<td width="12%"><a href="#">Tab4</a></td>
	<td width="10%">&nbsp;</td>
</tr>

Yes Pullo,

When user will visit page for example Home then topmenu_active css class will be applied other wise no class.

This will high light selected page.

something like following url

http://learnedstuffs.wordpress.com/2012/05/24/jquery-highlighting-the-menu-item-for-the-current-page/

The code on the page you linked to compares the current url (in the address bar) with the value of the href attributes of the menu’s anchor tags.

So, what do your urls look like?

Also, your href attributes currently have a value of “#” so this isn’t going to work as you expect.

Could you provide a link to the page where you are trying to make this work?

Hi ,

Thanks Pullo

I did this using session and it works.

-Thanks