Note that there are some explanatory texts on larger screens.

plurals
  1. POonClick addClass 'active' slideDown overlay div, close overlay div onClick next div
    primarykey
    data
    text
    <p>I've been trying to cobble together a script from various places on this site, but it's not working yet. What I need to happen is to click on a div and have the overlay div slide down, if a different div is clicked close the prev div and slide down the next. Here's my sort of working fiddle: <a href="http://jsfiddle.net/G94Vm/" rel="nofollow">http://jsfiddle.net/G94Vm/</a> </p> <p>HTML:</p> <pre><code>&lt;div class="item"&gt; &lt;div class="item-overlay"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="item"&gt; &lt;div class="item-overlay"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Script:</p> <pre><code>$(document).ready(function () { var open = $('.item'), a = $('div').find('.item-overlay'); open.click(function(){ var $this = $('.item-overlay', this), speed = 300; $this.addClass('active').slideDown(speed); if ($this.hasClass('active') === true) { $this.removeClass('active').next('.item-overlay').slideUp(speed); } else if (a.hasClass('active') === false) { $this.addClass('active').next('.item-overlay').slideDown(speed); } else { a.removeClass('active').next('.item-overlay').slideUp(speed); $this.addClass('active').next('.item-overlay').delay(speed).slideDown(speed); } }); </code></pre> <p>});</p> <p>This is the site I'm <a href="http://bozaandesign.com/newwebsite/" rel="nofollow">working on:</a> Which is just using this basic script right now:</p> <pre><code>$(document).ready(function () { $('.item', this).click(function () { $('.item-overlay', this).slideToggle('400', function () { // end animation }); }); </code></pre> <p>});</p> <p>I'm still learning jQuery and can't figure out what I'm doing wrong. Been at this for hours, any help would be very much appreciated.</p> <p>Thanks! John</p>
    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