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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:30:16+00:00 2026-05-30T05:30:16+00:00

Why does onmouseover run multiple times while I hover over one element? I’m trying

  • 0

Why does onmouseover run multiple times while I hover over one element?

I’m trying to run a simple animation when the user hovers over an icon but it runs multiple times.

I’m testing it here:

http://lujanventas.com/test.php

Anyway, any ideas on how to fix it? maybe using a listener instead?

This is the javascript running onmouseover:

function upIcon(n) {
    console.log("Mouseover icon: " + n);
    $('#icon' + n).animate({ backgroundPositionY : "-=15px" }, 200 );
    $('#icon' + n).animate({ backgroundPositionY : "+=15px" }, 200 );
    }
  • 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-30T05:30:18+00:00Added an answer on May 30, 2026 at 5:30 am

    Try using mouseenter and mouseleave instead of mouseover and mouseout. The former fires only when the cursor enters the region of the element and the latter fires when the cursor moves between descendants as well.

    I added this code to your page via my console and it worked as expected:

    //bind an event handler to each nav element for the mouseenter event
    $('.categoryButtons').children().bind('mouseenter', function () {
    
        //call the `upIcon` function with the index of the current element
        upIcon(($(this).index() + 1));
    });
    

    I also removed the inline onmouseover code for each nav item.

    Update

    You can use your existing function a bit differently and not use the anonymous function for your event handler (notice the function chaining to avoid duplicate selections):

    function upIcon(event) {
        var n = ($(this).index() + 1);
        $('#icon' + n).animate({ backgroundPositionY : "-=15px" }, 200 ).animate({ backgroundPositionY : "+=15px" }, 200 );
    }
    
    $('.categoryButtons').children().bind('mouseenter', upIcon);
    

    When you reference an existing function as the event handler, it gets passed the event object like any other event handler and you can also use this to refer to the element on which the event was triggered.

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

Sidebar

Related Questions

There are times when I have a choice between using a CSS element:hover or
Using Raphael, I'm trying to get a shape to appear when you hover over
Is it possible to add an onmouseover attribute to an input element where type
var e = jQuery.Event(onmouseover); e.attr(id); I want to get id of this element but
How does the following code need to be changed so when the onmouseover event
I am trying to add an onKeyPress event to a dynamically created html element
I am trying to add a simple delay to a mouseover event of a
Possible Duplicate: what does #someDiv mean? i am doing this: onmouseover=evt.target.setAttribute('opacity', '0.5'); $('#someDiv').show(); onmouseout=evt.target.setAttribute('opacity','1)');
Does Google force employees who have offers from Facebook to leave immediately?
Does anyone remember the XMP tag? What was it used for and why was

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.