Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:26:57+00:00 2026-05-27T20:26:57+00:00

Ok i got this situation <div id=container> <img src=images/4.png /> <ul class=menu> <li id=menu-0>

  • 0

Ok i got this situation

        <div id="container">
        <img src="images/4.png" />
        <ul class="menu">
            <li id="menu-0"> <p class="menuP" id="button0">                                                 </p></li>
            <li id="menu-1"> <p class="menuP" id="button1"> <a id="abutton1" onclick="animatedown1()">  </a></p></li>
            <li id="menu-2"> <p class="menuP" id="button2"> <a id="abutton2" onclick="animatedown2()">  </a></p></li>
            <li id="menu-3"> <p class="menuP" id="button3"> <a id="abutton3" onclick="animatedown3()">  </a></p></li>
            <li id="menu-4"> <p class="menuP" id="button4"> <a id="abutton4" onclick="animatedown4()">  </a></p></li>
            <li id="menu-5"> <p class="menuP" id="button5">                                                 </p></li>
        </ul>
    </div> 
    <div id="bgRepeat1"> 
        <div class="textContainer" id="textContainer1">  <!-- only one of these is visible at any given time -->                      
            <p> container 1 </p>
        </div>
        <div class="textContainer" id="textContainer2">
            <p> container 2 </p>
        </div>
        <div class="textContainer" id="textContainer3">
            <p> container 3 </p>
        </div>
        <div class="textContainer" id="textContainer4">
            <p> container 4 </p>
        </div>
    </div>

and this is the javascript i got for this

function animatedown1()
{
    alert('start1');
    $("#textContainer1").animate({  
        opacity:'0'
        },800, function(){
        alert('end1');});
}

it works in this 1st example , but it wont work in any other

function animatedown2()
{
    alert('start2');
    $("#textContainer2").animate({  
        opacity:'0'
        },800, function(){
        alert('end2');});
}

i think there is no need to post the other 2 ( animatedown3 and 4 )

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

basically an animated menu with no links to other pages , all in one page.

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

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.

Any help would be greatly appreciated.

PS: I tried making this with

$("#menu-1").click(function() {
    $("#textContainer1").animate({
        opacity:'0'
        },800, function(){
        alert('wtf');});
    });

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.

http://www.byforthewind.hit.bg/

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:26:58+00:00Added an answer on May 27, 2026 at 8:26 pm

    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.

    <div id="container">
    
        <ul class="menu">
            <li id="menu-0"><p class="menuP" id="button0"></p></li>
            <li id="menu-1"><p class="menuP" id="button1"><a id="abutton1" onclick="animateContainer($('#textContainer1 p'))">container 1 </a></p></li>
            <li id="menu-2"><p class="menuP" id="button2"><a id="abutton2" onclick="animateContainer($('#textContainer2 p'))">container 2 </a></p></li>
            <li id="menu-3"><p class="menuP" id="button3"><a id="abutton3" onclick="animateContainer($('#textContainer3 p'))">container 3 </a></p></li>
            <li id="menu-4"><p class="menuP" id="button4"><a id="abutton4" onclick="animateContainer($('#textContainer4 p'))">container 4 </a></p></li>
            <li id="menu-5"><p class="menuP" id="button5"></p></li>
        </ul>
    </div>
    <div id="bgRepeat1">
        <div class="textContainer" id="textContainer1">  <!-- only one of these is visible at any given time -->
            <p> container 1 </p>
        </div>
        <div class="textContainer" id="textContainer2">
            <p> container 2 </p>
        </div>
        <div class="textContainer" id="textContainer3">
            <p> container 3 </p>
        </div>
        <div class="textContainer" id="textContainer4">
            <p> container 4 </p>
        </div>
    </div>
    
    <script type="text/javascript">
        function animateContainer(container)
        {
            container.animate( { opacity :0 }, 800, function() { console.log("ended") } );
        }
    </script>
    

    How does this work?

    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.

    Instead of writing function animatedown1() and function animatedown2() and so on and on, I wrote a single function with the following signature function animateContainer(container) – 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Situation: We've got this DIV with thumbnails who need their src being changed on
I have got this situation: this is the photo: http://imageshack.us/photo/my-images/826/iconepe.png/ the two images are
I've got this strange situation going on. Imagejpeg is only working when I define
I've got a problem with this situation (i'll try to make it easier) -
I've got a situation like this: Table: FunTable ItemKey ItemName ItemPriceEffectiveDate ItemPrice 11 ItemA
I've got the following situation: <h2>This text is <span>pretty awesome</span></h2> I'm trying to give
I've got this complex situation. Created EF with Model first and here are my
I'm not entirely sure how I got to this situation but somehow I'm getting
I am refreshing openmp a bit, and got into this weird situation. Shaved off
Env: .NET 1.1 I got into this situation. Where I need to give a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.