Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the best way to resolve this is to make a reuse of the same function. Check the code here and tell me if it resolved your problem. </p> <pre><code>&lt;div id="container"&gt; &lt;ul class="menu"&gt; &lt;li id="menu-0"&gt;&lt;p class="menuP" id="button0"&gt;&lt;/p&gt;&lt;/li&gt; &lt;li id="menu-1"&gt;&lt;p class="menuP" id="button1"&gt;&lt;a id="abutton1" onclick="animateContainer($('#textContainer1 p'))"&gt;container 1 &lt;/a&gt;&lt;/p&gt;&lt;/li&gt; &lt;li id="menu-2"&gt;&lt;p class="menuP" id="button2"&gt;&lt;a id="abutton2" onclick="animateContainer($('#textContainer2 p'))"&gt;container 2 &lt;/a&gt;&lt;/p&gt;&lt;/li&gt; &lt;li id="menu-3"&gt;&lt;p class="menuP" id="button3"&gt;&lt;a id="abutton3" onclick="animateContainer($('#textContainer3 p'))"&gt;container 3 &lt;/a&gt;&lt;/p&gt;&lt;/li&gt; &lt;li id="menu-4"&gt;&lt;p class="menuP" id="button4"&gt;&lt;a id="abutton4" onclick="animateContainer($('#textContainer4 p'))"&gt;container 4 &lt;/a&gt;&lt;/p&gt;&lt;/li&gt; &lt;li id="menu-5"&gt;&lt;p class="menuP" id="button5"&gt;&lt;/p&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div id="bgRepeat1"&gt; &lt;div class="textContainer" id="textContainer1"&gt; &lt;!-- only one of these is visible at any given time --&gt; &lt;p&gt; container 1 &lt;/p&gt; &lt;/div&gt; &lt;div class="textContainer" id="textContainer2"&gt; &lt;p&gt; container 2 &lt;/p&gt; &lt;/div&gt; &lt;div class="textContainer" id="textContainer3"&gt; &lt;p&gt; container 3 &lt;/p&gt; &lt;/div&gt; &lt;div class="textContainer" id="textContainer4"&gt; &lt;p&gt; container 4 &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; function animateContainer(container) { container.animate( { opacity :0 }, 800, function() { console.log("ended") } ); } &lt;/script&gt; </code></pre> <p>How does this work? </p> <p>Well - instead of copy-pasting the same function again and again, I wrote the function once and I am passing the container I want to animate. </p> <p>Instead of writing <code>function animatedown1()</code> and <code>function animatedown2()</code> and so on and on, I wrote a single function with the following signature <code>function animateContainer(container)</code> - as you can see I pass the function which element I want to animate. This way I can reuse the same function again and again for any number of containers I want. </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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