Note that there are some explanatory texts on larger screens.

plurals
  1. POone button works , others dont , same script
    primarykey
    data
    text
    <p>Ok i got this situation</p> <pre><code> &lt;div id="container"&gt; &lt;img src="images/4.png" /&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="animatedown1()"&gt; &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="animatedown2()"&gt; &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="animatedown3()"&gt; &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="animatedown4()"&gt; &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; </code></pre> <p>and this is the javascript i got for this</p> <pre><code>function animatedown1() { alert('start1'); $("#textContainer1").animate({ opacity:'0' },800, function(){ alert('end1');}); } </code></pre> <p>it works in this 1st example , but it wont work in any other</p> <pre><code>function animatedown2() { alert('start2'); $("#textContainer2").animate({ opacity:'0' },800, function(){ alert('end2');}); } </code></pre> <p>i think there is no need to post the other 2 ( animatedown3 and 4 )</p> <p>ok so ... the basic idea is: i have 4 buttons , they are listed ( button0 and button5 don't do anything they are just listed) On click for example button1 , textcontainer1 should be shown and hide any that was shown before</p> <p>basically an animated menu with no links to other pages , all in one page.</p> <p>Now it works only if i click button1 , it hides textcontainer1(i know it should show it , this here is just to see if the button works) ,and that's good . The problem is here : when i click button2,3 or 4 nothing happens , i have implemented alert() in those buttons so i can see if the script kicks in but it just doesn't start , it works only for button1</p> <p>all 4 functions are almost identical , but if i found out that if i switch in animatedown1() the part $("#textContainer1") with $("#textContainer2") it works for textContainer2 .. so that makes me think that for some reason only the first function works.</p> <p>Any help would be greatly appreciated.</p> <p>PS: I tried making this with</p> <pre><code>$("#menu-1").click(function() { $("#textContainer1").animate({ opacity:'0' },800, function(){ alert('wtf');}); }); </code></pre> <p>but in here i cant make it register my click on menu-1 ( also tried with the ID's button2 and abutton2 ) Any solution with .click or with a onclick function would appreciated.</p> <p><a href="http://www.byforthewind.hit.bg/" rel="nofollow">http://www.byforthewind.hit.bg/</a></p> <p>EDIT : I found what was wrong ... when i checked my javascript i saw that just below all 4 functions , there were another 3 ( except the 1st ) with the same name but empty . That's why only the 1st function worked , the other 3 were overwritten by the empty ones on the bottom of the page.</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