Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Professional jQuery
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional jQuery
This is the forum to discuss the Wrox book Professional jQuery Cesar Otero, Rob Larsen; ISBN: 978-1-1180-2668-7
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional jQuery section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 6th, 2012, 12:39 PM
Authorized User
Points: 53, Level: 1
Points: 53, Level: 1 Points: 53, Level: 1 Points: 53, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to preserve link state or CSS class on a link (anchor tag) with cookies?

Hello,

I have this piece of code which adds and remove a class on my links.
The class is added to the linked clicked or active and removed from liked that are not active/clicked.

However I would like to preserve the state of the link so that it remain active, this is for a single page.

JQuery:

Code:
$(document).ready(function() {	
    $('.navbar li a').click(function(){
        $(".navbar li a").removeClass("currentTab");
        $(this).addClass("currentTab"); 
    }); 
});

Code:
<style type="text/css">
.currentTab{
color: #999999;
}
</style>
HTML:

Code:
<ul class="navbar">
<li><a href="#/">Test Link</a></li>
<li><a href="#/">Test Link</a></li>
<li><a href="#/">Test Link</a></li>
</ul>
Thanks everyone!

M
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
anchor link not working in IE6 sbkumar CSS Cascading Style Sheets 2 July 29th, 2008 11:27 AM
Anchor tag visited CSS related question mat41 Classic ASP Basics 0 April 16th, 2008 05:55 PM
link to anchor in a db-generated page scottiegirl PHP Databases 4 March 11th, 2008 12:19 PM
div tag as link Stagmo Dreamweaver (all versions) 0 April 14th, 2006 12:35 AM
Help with paginating and anchor link. major dynamic123 Pro PHP 6 September 11th, 2003 01:47 PM



All times are GMT -4. The time now is 10:42 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.