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 9000141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:16:24+00:00 2026-06-16T00:16:24+00:00

I have a simple color animation with jquery.color . This is my code: $(document).ready(function(){

  • 0

I have a simple color animation with jquery.color. This is my code:

$(document).ready(function(){
    $('.fx_link').bind({
        mouseenter: function(e) {
            $(this).attr('originalColor', $(this).css('color'));
            $(this).animate({ color: "#999999" }, 'fast');
        },
        mouseleave: function(e) {
            $(this).animate({ color: $(this).attr('originalColor') }, 'fast');
            $(this).removeAttr('originalColor');
        }
    });
});

And it is quite good. But, the animation is for menu items. If the mouse is on an item, the animation start. Then the mouse click and the page is refreshed. The mouse is on link but it is not moving. Sooner as the mouse moves just one pixel the mouseenter event is fired (even if the mouse is already on the link) and there is an animation that i consider a bug.

I would need somethink like:

$(this).bind({ mouseenter: function(e) {

    if( __ mouse is not already over $(this) __ ) 

        $(this).animate(...); } });

I have tried with some set state on mouseenter, mouseover but.. no way

EDIT:

full example. save this as h.html

<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://code.jquery.com/color/jquery.color-2.1.0.js"></script>
<script type="text/javascript">

$(document).ready(function(){

    $('.fx_link').bind({
        mouseenter: function(e) {
            console.log("enter");
            $(this).attr('originalColor', $(this).css('color'));
            $(this).animate({ color: "#999999" }, 'fast');
        },
        mouseleave: function(e) {
        
            console.log("leave");
            $(this).animate({ color: $(this).attr('originalColor') }, 'fast');
            $(this).removeAttr('originalColor');
        
        }
    });
});


</script>
<body>

<a class="fx_link" href="h.html">this is a link</a>

</body>
</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-16T00:16:24+00:00Added an answer on June 16, 2026 at 12:16 am

    Sorry, I’m on mobile phone so the code might be wrong (not tested).

    EDITED (and tested now)

    // fix: bind mousemove to document, not links, sorry!
    $(document).bind('mousemove', function(event) {
        $('.fx_link').bind('mouseenter', function(event) {
             //....
        }
        $(this).unbind(event);
    });
    

    EDITED

    • Full example with handling of 2 different mouseEnters one if [at page refresh] mouse is already inside link (just set the color), one when coming from outside (animate color).

    • Fixed originalColors bug by setting originalColors for all the links at start.

    • Used named functions instead of anonymous functions so it was easy to unbind (and looks more clear too).

    Here is the code:

    <html>
    <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/color/jquery.color-2.1.0.js"></script>
    <script type="text/javascript">
    
    $(document).ready(function(){
    
        var $links=$('.fx_link');
    
        // save ALL originalColors so they are fixed forever
        $links.each(function() {$(this).attr('originalColor', $(this).css('color'));});
    
        $(document).bind('mousemove', handleMove);
        $links.bind('mouseenter', firstMouseEnter);
        $links.bind('mouseleave', anyMouseLeave);
    
        function handleMove(event) { // When mouse moves in document
            console.log("first move - setting up things..");
            $(document).unbind('mousemove',handleMove); // remove myself (no need anymore)
            $links.bind('mouseenter', otherMouseEnter); // istall second mouseenter
            $links.unbind('mouseenter',firstMouseEnter); // remove first mouseenter
        }
    
        function firstMouseEnter(event) { // Called before mouse is moved in document
            console.log("first enter");
            $(this).css('color','#999');
        }
    
        function otherMouseEnter(event) { // Called after mouse is moved in document
            console.log("other enter");
            $(this).animate({ color: "#999" }, 'fast');
        }
    
        function anyMouseLeave(event) {
            console.log("leave");
            $(this).animate({ color: $(this).attr('originalColor') }, 'fast');
        }
    
    });
    
    
    </script>
    <body>
    
    <a class="fx_link" href="h.html">this is a link</a>
    
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following simple code, but it doesn,t work <ul> <li id=one onmouseover=this.style.background-color='white';>
I have what seems to be a simple issue. I have a jquery function
I want to implement this simple animation in knockout: function scroll(back) { var scrollContainer
I have a simple hover animation; i seperated mouseenter and mouseleave functions to define
Suppose I have this simple class: class Color attr_accessor :rgb def initialize(ary) @rgb =
We have a color animation that blends from red to white. Currently, this is
I have a simple program which is able to change the background color after
I have an anchor tag with some simple CSS: div { background-color: gray; /*
All of this is code is here: http://jsfiddle.net/yrgK8/ I have a news section which
so i have a swf with a simple animation- the div used to contain

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.