Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery function is not working as i planned, DIVs just disappear on click
    primarykey
    data
    text
    <p>I have a script here, and it works amazing, except for one small detail. It basically runs as click function that fades in and out certain DIVs on the click of a link. </p> <p>The problem is, however, that when you click ANYWHERE on the page, it removes the DIV and leaves an empty content area until you click one of the links. Obviously this is a problem.</p> <p>I can't use the exact code I'm using for NDA reasons, but here is same setup I am using with just some plain text in the divs.</p> <p>Just click the links to see the functionality, and then click anywhere else on the page (in the div, in the white space, whatever) and watch the div just disappear. I'm know that that is what the javascript is calling, but I don't know how to disable the click in the divs so this doesn't happen. Also, how to do that so it doesn't disable the link that are within that div. </p> <p>Any help is greatly appreciated. This website is a life saver. </p> <p>This is the original code I got off of this site edited to show my very basic layout. Basically a bunch of links that are inline and when clicked, they change a section of DIVS to another section of divs:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { var gLastH = null; var gLastId = null; $('.toggle').click(function(e) { $('.toggleh:visible').fadeOut('slow'); gLastId = $(this).attr('id'); console.log('#' + gLastId + 'h'); gLastH = $('#' + gLastId + 'h'); $(gLastH).fadeIn('slow'); e.stopPropagation(); }); $('*').click(function(e) { if ($(this).attr('id') != gLastId) { $(gLastH).fadeOut('slow'); } e.stopPropagation(); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="menubar"&gt; &lt;a href="#" onclick="return false;" class="toggle" id="toggle1" style="display: inline;"&gt; text here&lt;/a&gt; &lt;a href="#" onclick="return false;" class="toggle" id="toggle2" style="display: inline;"&gt; text here&lt;/a&gt; &lt;a href="#" onclick="return false;" class="toggle" id="toggle3" style="display: inline;"&gt; text here&lt;/a&gt; &lt;a href="#" onclick="return false;" class="toggle" id="toggle4" style="display: inline;"&gt; text here&lt;/a&gt; &lt;div class="toggleh" id="toggle1h"&gt; some description in here I suppose &lt;/div&gt; &lt;div class="toggleh" id="toggle2h" style="display: none;"&gt; some description in here I suppose #2dsfds sdfdsfa sdf &lt;/div&gt; &lt;div class="toggleh" id="toggle3h" style="display: none;"&gt; some description in here I suppose #3dffdfasdfdsfdfasf &lt;/div&gt; &lt;div class="toggleh" id="toggle4h" style="display: none;"&gt; some description in here I suppose #4 dfdafa &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload