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

  • Home
  • SEARCH
  • 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 8921683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:36:44+00:00 2026-06-15T06:36:44+00:00

I am making a menu where on rollover, the text of the link changes

  • 0

I am making a menu where on rollover, the text of the link changes (fades in). I just copied and pasted a block of code off another thread

<script type="text/javascript">
    function fade_new_text(){
        $('#what').animate({'opacity': 0}, 500, function () {
            $(this).text('new text');
        }).animate({'opacity': 1}, 500);
    }
    function revert(){
        $('#what').animate({'opacity': 0}, 500, function () {
            $(this).text('do something');
        }).animate({'opacity': 1}, 500);
    }
</script>

then in the body section I have the menu itself

<body>
    <a href="#" id="what" onmouseover="fade_new_text();" onmouseout="revert();">Do something</a>
</body>

This works well with one link, but I need to create 7 of them and hopefully reuse this code in the future. So I need to pass both the link id and the new text to Jquery function for 6 other links, hopefully from ‘onmouseover’ and ‘onmouseout’, as it would make the most sense? I am completely new to Jquery, and would appreciate your advice on how to do that.

The test file is at http://www.voxcommunications.ca/test.html

  • 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-06-15T06:36:47+00:00Added an answer on June 15, 2026 at 6:36 am

    Working off of Bryans answer, this way prevents recurring animations when unnecessary, also adds the data-mouseout dynamically instead of rewriting the Link Text in the data-mouseout on each link.

    Here is a working Example FIDDLE

    HTML

    <a class="hoverlink" data-mouseover="Hovering here">Do something</a><br />
    <a class="hoverlink" data-mouseover="Hovering again">Do something else</a><br />
    <a class="hoverlink" data-mouseover="Hovering some more">Do something yet again</a><br />
    <a class="hoverlink" data-mouseover="Hovering yet once more">Do something one last time</a><br />
    

    JQuery

    //Add the link text dynamically
    $('.hoverlink').each(function() {
        $(this).data('mouseout', $(this).text());
    });
    
    //Perform hover function and prevent recurring animations
    $("body").on("mouseover mouseout", '.hoverlink', function(event) {
    
        var text = $(this).data(event.type);
    
        $(this).stop().animate({"opacity": 0}, 500, function() {
            $(this).stop().text(text).animate({"opacity": 1}, 500);
        });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a pure css dropdown menu (code here: http://jsfiddle.net/SeXyv/7/ ) and I would
I'm making a game and in the menu I want to display the text
This is my code for my menu: /*Menu*/ #menu { text-align: right; margin-left: auto;
So i'm making a menu in a simple console app. My code is pretty
I'm making a navigation menu with background images. I managed to vanish the text
I'm making a menu with <ul> / <li> and CSS. Here's what I have
I am making a menu for an app and was pointed to this useful
I am making a menu test for the employees at my restaurant. The plan
I'm pretty new to HTML and CSS. I'm making a menu bar horizontal and
I am making a css menu. For this I am using a ul .

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.