Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8971455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:57:37+00:00 2026-06-15T17:57:37+00:00

I am using key shortcut to class toggling like below. // Toggle admin bar

  • 0

I am using key shortcut to class toggling like below.

// Toggle admin bar using Tab + q
key('tab + q', function(){
  $('body').toggleClass('admin')
});

But I would like to store that across sessions. How will be the best way to do that?

I tried use jQuery.cookie.js

// Toggle admin bar using Tab + q
if ($.cookie('adminBarVisible') == 'false') {
  $('body').removeClass('admin')
};

key('tab + q', function(){
  if ($.cookie('adminBarVisible') == 'true') {
    $('body').removeClass('admin')
    $.cookie('adminBarVisible', false)
  } else {
    $('body').addClass('admin')
    $.cookie('adminBarVisible', true)
  };
});

But on refresh for a while (0.5sec) I see admin bar on top.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:57:38+00:00Added an answer on June 15, 2026 at 5:57 pm

    You can use either:

    • cookies – most cross-browser solution, utilize document.cookie (or any other cookie javascript plugin out there) to access cookie value in condition when checking if something should be toggled initially. There would be additional value when using cookies, since cookies are send to your server with every request, hence making themselfs available for server side use.
    • localStorage – easy to use, available on newer browsers, data is persisted accross sessions.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I added shortcut key on my control using jquery. $(function() { shortcut.add(ctrl+r, function() {
I am using ruby key & value fields to save a jquery function to
How can I define an aquamacs keyboard shortcut using the mac command key. I'd
I'm using a similar codesnippet as shown below to add an application shortcut on
I wrote global shortcut example for hide and show my windows with key like
Using Visual Studio 2008 Team Edition, is it possible to assign a shortcut key
The shortcut key is F11 to start debugging. But issue is that I have
Using zsh, i would like to add a shortcut to go in parent directory.
I'm using key value observing on a boolean property an NSObject method: -(void)observeValueForKeyPath:(NSString *)keyPath
In C, how to configure the initial settings for some program, using key-value pairs,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.