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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:53:38+00:00 2026-05-22T21:53:38+00:00

I have a problem with JQuery Toggle. I have the following code: var $_

  • 0

I have a problem with JQuery Toggle.

I have the following code:

var $_ = jQuery;
$_(document).ready(function(){

$_("#sh-zone-buttons").delegate("#sh-zone-button-login-menu", "click", function(event)
{
    event.stopPropagation();
    event.preventDefault();
    var elem_core = $_(this);
    $_("#sh-zone-login-menu").toggle(0, function(){

        if($_(this).is(":visible"))
        {
            $_(this).hide();
            console.log("#sh-zone-login-menu: HIDE");
        }
        else if(!($_(this).is(":visible")))
        {
            $_(this).show();
            console.log("#sh-zone-login-menu: SHOW");
        }           

    });
    elem_core.toggleClass("current");       

});

});

I’m using the script to show and hide a DIV. However, toggle() doesn’t seem to work at all and I don’t know why. What happens is that it only shows the content, and never hides. I’ve also tried it with just the toggle() function but it gives me the same result.

I’m using Firefox 4 with JQuery 1.5.2.

I’d appreciate any assistance to resolve this.

  • 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-22T21:53:38+00:00Added an answer on May 22, 2026 at 9:53 pm

    I seem to have figured this one out, but it spooks the daylight out of me.

    Here the HTML code for the DIV I wanted to toggle:

    <div id="sh-zone-login-menu" class="sh-zone-button-link-menu-container">
    <fieldset>
        <form action="#" method="post" enctype="multipart/form-data">
            <p>
            <label for="email">Username or Email</label>
            <input type="text" name="email" maxlength="255" value="" />
            </p>
            <p>
                <label for="email">Password</label>
                <input type="password" name="password" maxlength="20" value="" />
            </p>
            <p class="remember">
                <input type="submit" value="Sign in" />
                <input type="checkbox" name="remember" value="1" />
                <label for="remember">Remember me</label>
            </p>
            <p>
                <a href="#">Forgot your password?</a>
            </p>
            </form>
    </fieldset>
    </div>
    

    Using this code above, the toggle doesn’t work.

    But when I take out the fieldset tags, the toggle works. For the life of me I can’t explain why this is working, but not the code above.

    I’ve disabled all my script tags except the one for jQuery, and all my javascript code except the one to toggle and I still get the same phenomenon.

    However, in jsFiddle (http://jsfiddle.net/bBXhD/2/), I don’t see the issue. Has anyone come across anything like this?

    Anyway, thanks all for the responses.


    Additional Note: 06-06-2011 15:41

    Just in case someone runs into a similar issue later, I just thought I’d document my recent finding on this. The problem was from the CSS and HTML. Although the fieldset tag was not the problem, it was removed as I believe it’s not even semantically accurate to encapsulate a form with this tag.

    The problem was from the container div i.e. class=”sh-zone-button-link-menu-container”. This container was specifically positioned as absolute in CSS. In addition, the form was also positioned as absolute in CSS. When this happens, JQuery toggle() will not work, I’m not sure why this is. What I did to resolve this was remove the position declaration from the CSS for the form tag.

    You can have a look at both examples on JSFiddle here:

    a. Not working JQuery toggle (http://jsfiddle.net/bBXhD/4/)

    b. Working JQuery toggle (http://jsfiddle.net/bBXhD/5/)

    Cheers.

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

Sidebar

Related Questions

I have this JQuery function: $(document).ready(function() { $(div.descript_long).each(function() { var descript_length = $(div.descript_long).text().length; if(descript_length
I have a problem with this jquery script. toggle:function() { if(this.opened){ $(slideToBuyBottomBtnClosed).setStyle(display,block); $(slideToBuyBottomBtnOpen).setStyle(display,none); $(sildeToBuyContent).setStyle(overflow,hidden);
I have found this code (jQuery): $('.toggle').click(function() { $('.container').eq($(this).index()).toggle('fast'); }); This is my HTML:
I have a problem with this Jquery function. The the simplifide code looks like:
Assuming I have the following two JQuery functions - The first, which works: $(#myLink_931).click(function
i have a problem with the jquery post. my vars var checki = '1';
I have my wordpress post content hidden using a jquery toggle effect. The problem
I have a problem with this jQuery code. It doesn't work as expected: $('#select_dropdown').change
I am using following jQuery code to toggle between the tabs on a page:
I have a problem with the jquery-ui dialog box . The problem is that

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.