Note that there are some explanatory texts on larger screens.

plurals
  1. POOpening and closing boxes when a div is clicked
    primarykey
    data
    text
    <p>I'm running some jQuery on my site that opens and shuts boxes when a div is clicked.</p> <p>I have the following;</p> <pre><code>$(document).ready(function(){ $('.hide-text').hide(); $('.hidden_answer').hide(); $('.show-text').click(function(){ $('.hide-text').toggle(100); }); $('.home_questions_top').click(function(){ $(this).next('.hidden_answer').slideToggle(200); }); </code></pre> <p>This is the HTML structure. There are about 7 or 8 of these blocks of code in a row;</p> <pre><code> &lt;div class="home_questions_top"&gt; &lt;h3&gt;Test&lt;/h3&gt;&lt;div class="arrow"&gt;&lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt;&lt;!--home questions top--&gt; &lt;div class="hidden_answer"&gt; &lt;p&gt;blah blah blah blah&lt;/p&gt; &lt;/div&gt; &lt;div class="closed_blue"&gt;&lt;/div&gt; &lt;div class="home_questions_bottom"&gt;&lt;/div&gt; </code></pre> <p>So far, you click the top div and the "hidden answer" opens. I would like to make the jQuery a little different though, can I make it so when you open the box by clocking the top div it opens as it does now, but when you like a different div (one of the other 7 or 8 I said about) this one shuts, and that one opens. So basically only one can be open at a time?</p> <p>The other idea I had is not as important but would be cool. At the moment the div class "arrow" contains a background image of arrow pointing down, it would be great to make it point up when the box is opened, maybe by rotating 180 or just switching the background image....</p> <p>Any advice is welcome, thanks!</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