Note that there are some explanatory texts on larger screens.

plurals
  1. POif statement checking that div hasClass
    primarykey
    data
    text
    <p>hi i want to write if statement which is checking if div dont hasClass and if dont has it script should add it using toggleClass (i'm useing jquery ui), i wrote script above whitch is working almost fine but the first (this) should point to (.apla) that has not "min" class and the second (this) should point (.apla) with clicked (.arrow)</p> <p>point of this is to check if any (.apla) is open and if any (.apla) is open script should close it using toggleClass (with animation), and after this script should open clicked (.apla) also using toggleClass, could u help me pls </p> <p>fiddle - <a href="http://jsfiddle.net/eNqew/" rel="nofollow">http://jsfiddle.net/eNqew/</a></p> <p>JS</p> <pre><code>$('.arrow').click(function(){ if (!$(".apla").hasClass("min")) { $(this).toggleClass("min", "slow"); } else { $(this).parent().parent().toggleClass("min", "slow"); } }); </code></pre> <p>UPDATE JS works almost</p> <pre><code>$('.arrow').click(function(){ if (!$("#apla01").hasClass("min")) { $("#apla01").toggleClass("min", "slow"); } if (!$("#apla02").hasClass("min")) { $("#apla02").toggleClass("min", "slow"); } if (!$("#apla03").hasClass("min")) { $("#apla03").toggleClass("min", "slow"); } else { $(this).parent().parent().toggleClass("min", "slow"); } }); </code></pre> <p>HTML</p> <pre><code>&lt;div id="apla01" class="apla min"&gt; &lt;div class="apla-wraper"&gt; &lt;div class="arrow"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="apla02" class="apla min"&gt; &lt;div class="apla-wraper"&gt; &lt;div class="arrow"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="apla03" class="apla min"&gt; &lt;div class="apla-wraper"&gt; &lt;div class="arrow"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS</p> <pre><code>#apla01.apla.min { z-index: 5; left: -800px; } #apla02.apla.min { z-index: 4; left: -760px; } #apla03.apla.min { z-index: 3; left: -720px; } .apla { width: 838px; height: 634px; position: absolute; top: 20px; left: 0; background: url(../img/bgApla.png) no-repeat -5px center; } .apla.min { } .apla-wraper { position: relative; width: 100%; height: 100%; } .arrow { width: 28px; height: 28px; background: url(../img/arrow.png) no-repeat 0 0; position: absolute; top: 50%; right: -10px; margin-top: -14px; cursor: pointer; } .apla.min .arrow{ background: url(../img/arrow.png) no-repeat -28px 0; } </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