Note that there are some explanatory texts on larger screens.

plurals
  1. POChange image source of span, once content area slide happened
    primarykey
    data
    text
    <p>I currently have a problem. I built some kind of accordion on a website. Sliding works all fine, however, when I try to write a function to change the image src of the icon it does not work.</p> <p>I have 3 span6, with the ID's swap1 to swap3. swap1 is visible at beginning, swap 2 and 3 are hidden.</p> <p>This is my markup, here for swap1 only. swap2 and swap3 are built up the same:</p> <pre><code>&lt;div id="swap1" class="span6"&gt; &lt;h3&gt;Lorem Ipsum dolor sit amet? &lt;span class="expand"&gt;&lt;img src="images/minus.png" /&gt;&lt;/span&gt; &lt;/h3&gt; &lt;p&gt;Lorem Ipsum dolor sit amet.....&lt;/p&gt; &lt;/div&gt; </code></pre> <p>This is the jQuery:</p> <pre><code>$(document).ready(function() { console.log('logging'); $('#swap2.span6 p').hide(); $('#swap3.span6 p').hide(); $(function() { $('#swap1 .expand').click( function() { $('#swap1.span6 p').slideToggle(); $( "#swap1 .expand" ).attr('src', 'images/plus.png').load(function(); }); $('#swap2 .expand').click( function() { $('#swap2.span6 p').slideToggle(); $( "#swap1 .expand" ).attr('src', 'images/minus.png').load(function(); }); $('#swap3 .expand').click( function() { $('#swap3.span6 p').slideToggle(); $( "#swap1 .expand" ).attr('src', 'images/minus.png').load(function(); }); }); }); </code></pre> <p>First of all, the sliding works, the image src changing not at all. Second, I'm stuck with what happens after you slided. The image would stay at the changed state and would not change back regardless of the state (expanded/collapsed). I'm currently stuck, I tried to look it up how other accordions work, but nothing really helped. </p> <p><a href="http://jsfiddle.net/K2GpC/2/" rel="nofollow">http://jsfiddle.net/K2GpC/2/</a></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.
 

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