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 7590207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:20:40+00:00 2026-05-30T20:20:40+00:00

I am using jquery tool for tab Ui, Now I want to keep tab

  • 0

I am using jquery tool for tab Ui,

Now I want to keep tab selected on page reload. Is there any way to do that? below is my code

$(function() {
    // setup ul.tabs to work as tabs for each div directly under div.panes
    $("ul.tabs").tabs("div.panes > div");
});
  • 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-05-30T20:20:41+00:00Added an answer on May 30, 2026 at 8:20 pm

    Here is a simple implementation of storing the cookie and retrieving it:

    function getCookie(c_name) {
        var i, x, y, ARRcookies = document.cookie.split(";");
        for (i = 0; i < ARRcookies.length; i++) {
            x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
            y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
            x = x.replace(/^\s+|\s+$/g, "");
            if (x == c_name) {
                return unescape(y);
            }
        }
    }
    
    function setCookie(c_name, value, exdays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + exdays);
        var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
        document.cookie = c_name + "=" + c_value;
    }
    

    Then, to save/retrieve cookie data with jQuery UI Tabs:

    $(function() {
       // retrieve cookie value on page load
       var $tabs = $('ul.tabs').tabs();
       $tabs.tabs('select', getCookie("selectedtab"));
    
       // set cookie on tab select
       $("ul.tabs").bind('tabsselect', function (event, ui) {
          setCookie("selectedtab", ui.index + 1, 365);
       });
    });
    

    Of course, you’ll probably want to test if the cookie is set and return 0 or something so that getCookie doesn’t return undefined.

    On a side note, your selector of ul.tabs may be improved by specifying the tabs by id instead. If you truly have a collection of tabs on the page, you will need a better way of storing the cookie by name – something more specific for which tab collection has been selected/saved.

    UPDATE

    Ok, I fixed the ui.index usage, it now saves with a +1 increment to the tab index.

    Here is a working example of this in action: http://jsbin.com/esukop/7/edit#preview

    UPDATE for use with jQuery Tools

    According the jQuery Tools API, it should work like this:

    $(function() {
       //instantiate tabs object 
       $("ul.tabs").tabs("div.panes > div");
    
       // get handle to the api (must have been constructed before this call)
       var api = $("ul.tabs").data("tabs");
    
       // set cookie when tabs are clicked
       api.onClick(function(e, index) {
              setCookie("selectedtab", index + 1, 365);
       });     
       // retrieve cookie value on page load
       var selectedTab = getCookie("selectedtab");
    
       if (selectedTab != "undefined") {
        api.click( parseInt(selectedTab) ); // must parse string to int for api to work
       }
    
    });
    
    function getCookie(c_name) {
        var i, x, y, ARRcookies = document.cookie.split(";");
        for (i = 0; i < ARRcookies.length; i++) {
            x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
            y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
            x = x.replace(/^\s+|\s+$/g, "");
            if (x == c_name) {
                return unescape(y);
            }
        }
    }
    
    function setCookie(c_name, value, exdays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + exdays);
        var c_value = escape(value) + ((exdays === null) ? "" : "; expires=" + exdate.toUTCString());
        document.cookie = c_name + "=" + c_value;
    }
    

    Here is a working (unstyled) example: http://jsbin.com/ixamig/12/edit#preview

    Here is what I see in Firefox when inspecting the cookie from the jsbin.com example:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using jQuery, is there a way to select all tag that reference a specific
Using jQuery, how do you check if there is an option selected in a
I have created a tool using jQuery that will show certain table rows depending
I m havin a jqueryui modal form. and i m using jquery cluetip tool
Using jQuery, how do you bind a click event to a table cell (below,
Using jQuery, what's the best way to find the next form element on the
using jquery v1.3.2 and jQuery UI 1.7.1 I have 1 tab control with 3
I want to count how many divs with the class .tool that contain the
i try to create image resizer tool using jquery UI. here is the file
We are using jQuery 1.5.1 on the site that I'm working on. I recently

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.