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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:19:06+00:00 2026-06-03T21:19:06+00:00

Please don’t forget to upvote the great answer by my eventual savior Beetroot-Beetroot! I’ve

  • 0

Please don’t forget to upvote the great answer by my eventual savior Beetroot-Beetroot!

I’ve got this problem where .toggle() only shows on click, it never hides.

TL;DR: It normally looks like the screenshot below but the .toggle(); doesn’t hide when I click a second time.

The first div appears on a mouseover of the actual select box, taking any clicks it would receive on itself.

Normally clicking the first div which is the small div with 1px black border will show the second div, which works, and clicking again will hide it, which doesn’t work.(the click event works, the toggle fails)

screenshot

Here’s the html of the elements, yeah it’s normally within a table cell:

<td style="vertical-align: top; text-align: left;">
<select class="placeholder0" id="sortedselect0">
<option selected="selected">- for - </option>
<option>adj. &nbsp; foraminated</option>
<option>adj. &nbsp; foraminiferous</option>
<option>adj. &nbsp; foraminous</option>
<option>adj. &nbsp; forbearant</option>
<option>adj. &nbsp; forbearing</option>
<option>adj. &nbsp; forbidden</option>
<option>adj. &nbsp; forbiddenly</option>
<option>adj. &nbsp; forbidding</option>
<option>adj. &nbsp; forblack</option>
<option>adj. &nbsp; forby</option>
<option>AND MANY MORE OPTIONS</option>
</select>

<div class="anti" id="anti0" style="height: 18px; width: 179px; position: absolute; top: 209px; left: 494px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: black; border-right-color: black; border-bottom-color: black; border-left-color: black; border-image: initial; background-color: transparent; display: block; "></div>

<div class="floats" style="display: none; position: absolute; top: 227px; left: 494px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: black; border-right-color: black; border-bottom-color: black; border-left-color: black; border-image: initial; " id="floatdiv0"><img style="width: 222px; height: 342px;" alt="" src="fake_iframe.png"></div>

Then the javascript which follows it directly

<script type="text/javascript">
//make original select box unselectable
jQuery(".placeholder0").mouseover(function() {
    var pos = jQuery(this).position();
    var width = jQuery(this).outerWidth();
    var height = jQuery(this).outerHeight();

    jQuery("#anti0").css({
        height: (height - 2) + "px",
        width: (width - 2) + "px",
        position: "absolute",
        top: pos.top + "px",
        left: pos.left + "px",
        border: 1 + "px solid black",
        z: 2,
        "background-color":"transparent"
    });
});

jQuery("#floatdiv0").unbind('click');

jQuery("#anti0").live('click', function(){

    // .position() uses position relative to the offset parent,
    // so it supports position: relative parent elements
    var pos = jQuery(this).position();

    // .outerWidth() takes into account border and padding.
    var width = jQuery(this).width();
    var height = jQuery(this).height();

//first hide any other fake selects
jQuery("div.floats").hide();
//and antiselect overlays
jQuery("div.anti").hide();

//unhide current antiselect overlay
jQuery("#anti0").show();

    //show the menu directly over the placeholder
    jQuery("#floatdiv1").css({
        position: "absolute",
        top: (pos.top + height) + "px",
        left: pos.left + "px",
        border: 1 + "px solid black",
        //padding: height + "px",
        z: 1    
    });
    jQuery("#floatdiv1").toggle();
});

//hides the menu  
jQuery("#floatdiv1").mouseleave(function() {
    jQuery("#floatdiv1").hide();
    //and unhide overlays
    jQuery("div.anti").show();
});
</script><br>
</td>

I threw the .unbind in there just to try, I’m not even sure what it’s for I’m afraid.

Same happened with live, just .click was fine.

//hides the menu was my old way of hiding the div window, just leaving it, which worked flawlessly.

I was considering resorting to

{
    if ( showOrHide == true ) {
        jQuery('#floatdiv1').show();
    } else if ( showOrHide == false ) {
        jQuery('#floatdiv1').hide();
    }
}

but I tested it and it didn’t work so perhaps I’m doing it wrong?

I wanted to add an example of the problematic code at work but somehow mister problem.php is completely not working when I copy the code from the usual pages to this new php page.

Please help me just toggle this div one way or another. >.<

  • 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-03T21:19:08+00:00Added an answer on June 3, 2026 at 9:19 pm

    With some assumptions …

    Inside the click handler :

    jQuery("div.floats").hide();
    ...
    jQuery("#floatdiv1").toggle();
    

    As #floatdiv1 also has class="floats", the nett effect of the command sequence above will always be to show it.

    Try :

    jQuery("div.floats").not("#floatdiv1").hide();//hide all other floats
    ...
    jQuery("#floatdiv1").toggle();//toggle this float
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update3: If you like this posting please don't upvote me but upvote the genius
Please don't crucify me for this one. I decided it might be good to
Please don't send me a link to php.net referencing mysql_real_escape_string as the only response.
Please don't beat me if this is elementary. I searched and found disjointed stuff
I have a bunch of php arrays that look like this (please don't ask
I don't mean for this to be inflammatory, so please don't take it that
I found only related topic for c# please don't blame me if I missed
I have a very strange problem , please don’t ask me why do I
I am new to multithread programming, please don't laugh if this seems too simple.
Please don't answer the obvious, but what are the limit signs that tell us

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.