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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:51:26+00:00 2026-05-24T06:51:26+00:00

I have a mousenter/mouseleave function that swaps out content when the element is being

  • 0

I have a mousenter/mouseleave function that swaps out content when the element is being hovered over. however instead of it firing only on mouseenter it seems to keep continuously firing. I have created a jsfiddle here so hopefully it will be easier to understand.

  • 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-24T06:51:27+00:00Added an answer on May 24, 2026 at 6:51 am

    Inside your rotate_start() and rotate_reset() functions you are triggering a hover event via this line:

    jq('.product-image-container',super_prod).attr('hover','true');
    

    Per JQuery docs, hover() method binds handlers for both mouseenter and mouseleave events. You’re basically applying recursion unintentionally, as hover is fired as the mouse moves.

    A simple fix for this is to replace .attr('hover','true'); with .data('hover',true);

    Here is a scalable solution which should accomplish your objective:

    HTML:

    <div class="item">
        <ul>
            <li>
                Main product photo
            </li>
            <li>
                Alternate product photo 1
            </li>
            <li>
                Alternate product photo 2
            </li>
            <li>
                Alternate product photo 3
            </li>
        </ul>
    </div>
    

    CSS:

    .item {
        width:200px;
        height:200px;
        background-color:#F0F0F0;
        border:1px solid #666;
    }
    .item ul li {
        display:none;
    }
    

    JQuery:

    var jq = jQuery.noConflict();
    var timers = [];
    var interval_seconds = 2;
    
    jq('.item').mouseenter(function() {
    
        // Scope this
        var _this = jq(this);
    
        // Self-executing function
        (function cycle() {
    
            // Recursive setTimeout accommodates for animation time - setInterval wont
            timers['item'] = setTimeout(function() {
    
                // Grab the currently visible photo, and the next photo
                var _this_li = _this.find('li:visible');
                var _next_li = _this_li.next();
    
                // If there is no next photo, cycle back to first photo
                if (_next_li.length == 0) {
                    _next_li = _this.find('li:first-child');
                }
    
                // Animate the rotation
                _this_li.fadeOut('slow', function() {
                    _next_li.fadeIn('slow', function() {
    
                        // Recursion
                        cycle();
                    });
                });
            }, interval_seconds * 1000);
        })();
    });
    
    jq('.item').mouseleave(function() {
    
        // Stop the recursive setTimeout
        clearTimeout(timers['item']);
    
        // Scope this
        var _this = jq(this);
    
        // Grab the first photo in the list
        var _first_li = _this.find('li:first-child');
    
        // If the first photo in the list is not the currently visible photo, make it so.
        if (_first_li.not(':visible')) {
            _this.find('li:visible').fadeOut('slow', function() {
                _first_li.fadeIn('slow');
            });
        }
    });
    
    jq(function() {
    
        // Show the first photo on load
        jq('.item').find('li:first-child').fadeIn('slow');
    });
    

    Demo: http://jsfiddle.net/AlienWebguy/EY8mM/1/

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

Sidebar

Related Questions

I have the following Javascript/jQuery function: function addEventHandler(){ $(div).mouseenter(function() { $(this).html(Over); }).mouseleave(function() { $(this).html(Out);
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
I have a function that binds to a tr tag to provide a mouseover
hi i have a function that worked fine using jQuery 1.3.2 but now i
I have an <input type=range> scroll and a div that on mouseover and mouseleave
This is what I have currently: $(#cart-summary).mouseenter(function () { $('.flycart').delay(500).slideDown('fast'); }); $(.flycart).mouseleave(function () {
I have a piece of code that basically says: if you roll over this
I have this code: $(div[id^='intCell']).mouseover(function() { $(this).css({ border:,1px solid #ff097c}); }).mouseout(function() { $(this).css({border:,1px solid
I have a web page with DIV s with a mouseover handler that is
I have some javascript code that creates an img tag with a mouseover callback,

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.