开发者

Jquery, how to get cookies plugin to remember current class on anchor tag

I currently have the jquery code below that was refi开发者_JS百科ned by RJD22

$('.textResizing ul a').click(function(){
    $('.textResizing ul a').removeClass('current');
    $(this).addClass('current');
});

I am using the Jquery Cookies Plugin and I would like to know how I can get cookies to remember the current class state after refresh.

Thanks,

Sat


Maybe take a look at this page: Setting cookies with jQuery.

As far as I can see you can set whole objects in a cookie so you can read it out again after refresh and set that class to the element you want.

This would look somewhat like this:

$.cookie("myState", { 'myClassToRemember' : 'current', 'myOtherThingToRemember' : 'someothervalue' });

After the refresh you do something like:

var state = $.cookie("myState");
$('.textResizing ul a').addClass(state.myClassToRemember);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜