Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery - fade out when clicking on parent element (and not the parents children)?
    primarykey
    data
    text
    <p>I've got the following code on my page, and what i'm trying to do is that when a user clicks outside the #loginBox, i want the entire #loginOverlay to fadeout. But i can't achieve this effect without having the fadeout triggered by clicking on #loginBox...</p> <p>It's placed on the bottom of the page, and i have a link on the page that triggers the fadein. But the fadeout is a bit struggling now tbh.</p> <p>I tried doing this:</p> <pre><code>$("#loginOverlay").click(function() { ...fadeout... }); </code></pre> <p>but it gives me the same result.</p> <p>So any suggestions? Thanks in advance!</p> <pre><code>&lt;div id="loginOverlay"&gt; &lt;div id="loginBox"&gt; &lt;img class="closeBtn" src="images/icons/close.png" alt="" /&gt; &lt;h3&gt;Login&lt;/h3&gt; &lt;form action="login.php?ref=index.php" method="post"&gt; &lt;input type="text" name="username" value="Username..." onblur="if(this.value.length == 0) this.value='Username...';" onclick="if(this.value == 'Username...') this.value='';" /&gt; &lt;input type="password" name="password" value="Password..." onblur="if(this.value.length == 0) this.value='Password...';" onclick="if(this.value == 'Password...') this.value='';" /&gt; &lt;input class="loginBtn" type="submit" name="submit" value="Login!" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;!--login box --&gt; &lt;/div&gt; &lt;script src="js/jquery-1.4.2.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function() { $('#loginOverlay').css('display', 'none'); $('#loginToggle').click(function() { $("#loginOverlay").fadeIn(200); }); $("#loginBox").parent().click(function(){ $("#loginOverlay").fadeOut(100); }); }); </code></pre>
    singulars
    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.
    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