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

  • SEARCH
  • Home
  • 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 861913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:03:21+00:00 2026-05-15T09:03:21+00:00

$(document).ready(function () { $(.LeftColumn).hide(); $(.SidebarToggle).toggle(function () { $(this).addClass(active); $(this).text(Hide Sidebar); $(this).attr(title, Hide Sidebar); $(.LeftColumn).fadeIn(fast);

  • 0
$(document).ready(function () {
            $(".LeftColumn").hide();
            $(".SidebarToggle").toggle(function () {
                $(this).addClass("active");
                $(this).text("Hide Sidebar");
                $(this).attr("title", "Hide Sidebar");
                $(".LeftColumn").fadeIn("fast");
                return false;
            },
            function () {
                $(this).removeClass("active");
                $(this).text("Show Sidebar");
                $(this).attr("title", "Show Sidebar");
                $(".LeftColumn").fadeOut("fast");
                return false;
            });

            $(document).mouseup(function () {
                $('.LeftColumn').fadeOut('fast');
                $('.SidebarToggle').removeClass("active");
                $('.SidebarToggle').text("Show Sidebar");
            })
        });

The problem I have is when the user clicks elsewhere on the page it will hide the LeftColumn as I want, but the Toggle function doesn’t know this so when the user clicks the SidebarToggle link it wont show the LeftColumn as it treats it as hiding. How can I fix this?

Thanks

  • 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-15T09:03:22+00:00Added an answer on May 15, 2026 at 9:03 am

    In this case, instead of .toggle(), use .click() and detect the state inside by checking for that active class with .hasClass(), like this:

    $(function () {
      $(".LeftColumn").hide().click(function(e) { e.stopPropagation(); }); 
      $(".SidebarToggle").click(function () {
        if($(this).hasClass("active")) {
          $(this).removeClass("active")
                 .text("Show Sidebar")
                 .attr("title", "Show Sidebar");
          $(".LeftColumn").fadeOut("fast");      
        } else {
          $(this).addClass("active")
                 .text("Hide Sidebar")
                 .attr("title", "Hide Sidebar");
          $(".LeftColumn").fadeIn("fast");
        }
        return false;
      });
      $(document).click(function () {
          $('.LeftColumn').fadeOut('fast');
          $('.SidebarToggle').removeClass("active")
                             .text("Show Sidebar");
      });
    });
    

    You can try a demo here

    This way, you don’t need to worry about the state of the .toggle() functions, you’re checking as you click 🙂

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

Sidebar

Related Questions

$(document).ready(function() { //Default Action $(.tab_content).hide(); //Hide all content $(ul.tabs li:first).addClass(active).show(); //Activate first tab $(.tab_content:first).show();
$(document).ready(function() { // #login-box password field $('#password').attr('type', 'text'); $('#password').val('Password'); }); This is supposed to
$(document).ready(function () { $(#divHeader)) { $(this).hover(function () { $(this).find('#edit').show(); $(this).find('#spandate').removeClass(datetime); $(this).find('#spandate').addClass(edit); }, function ()
$(document).ready(function(){ $('.submit').click(function(){ var value = $('#Name').attr('value'); alert(value); }); }); <input type=text value=10 id=Name/>Hello world
$(document).ready(function() { $(:input).focusout(function () { var a= $(this).closest(tr).attr('id'); var b= $(this).closest(td).attr('id'); var data =
jQuery(document).ready(function($) { $('input[type="text"]').live('focus', function() { if (this.value == 'someValue') { this.select(); } }); });
$(document).ready(function(){ $('.choices a img').click(function(e) { var url = $(this).attr('href') + ' .con_cen2'; $('.con_cen').html('loading...').load('signup.html'); e.preventDefault();
jQuery(document).ready(function(){ $(function() { $('.button-a').each(function() { $(this).hover( function () { $('.button-title', this).animate({ opacity: 0.6 },
$(document).ready(function(){ $(a).click(function() { $(#content).load($(this).attr(href)); window.location.hash = $(this).attr(href); return false; }); }); So I use
jQuery(document).ready(function () { $lstAccountType = $('select[id*=account_type]'); $lstAccountType.change(function () { $(this).remove('option[text=select one]') }); }); I

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.