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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:59:40+00:00 2026-05-28T18:59:40+00:00

I’m trying to make a menu where there are elements shown in plain text,

  • 0

I’m trying to make a menu where there are elements shown in plain text, and when you hover over them there are fields revealed to edit the plain text.

You can see an example here: http://jsfiddle.net/Bx7vX/9/

The timer variable is declared globally, so when you hover over a second list element really quickly, it clears the timer for the previous element. However, when I declare the timer inside of the function (seen here: http://jsfiddle.net/JYavJ/), the multiple elements will fade out correctly, but when you hover off of an element and then back on, it won’t clear the timer correctly.

So basically, I’m having an issue with keeping the timer variable persistent between hovers on a single element. I’ve tried adding the timer variable to the DOM element with no success. If someone knows how to solve this issue, or maybe a better way to approach this menu style entirely, I’d much appreciate it. Thanks!

For reference, here’s the code with the timer declared outside of the hover function:

$('.diet_draggable').hover(function() {
var timer;
var current = $(this);

if (current.is(':hover')){
    clearTimeout(timer);
    $(this).children(".static_units").hide();
    $(this).children(".mod_units").show();
}

else if (current.children('.mod_units').children('.list_amount').is(":focus")) {
    current.children('.mod_units').children('.list_amount').blur(function() {
        timer = setTimeout(function() {
            current.children(".mod_units").fadeOut(300);
            current.children(".static_units").fadeIn(300);
        }, 500);
        if (current.is(':hover')) clearTimeout(timer);
    });
}
else {
    timer = setTimeout(function() {
        current.children(".mod_units").fadeOut(300);
        current.children(".static_units").fadeIn(300);
    }, 500);
}
});
  • 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-28T18:59:42+00:00Added an answer on May 28, 2026 at 6:59 pm

    Here you are, this version is much simpler but works exactly as you want:

    var dietDraggable = function(element) {
    var timer = null;
    
    element.hover(function() {
        clearTimeout(timer);
        $(this).children(".static_units").hide();
        $(this).children(".mod_units").show();
    }, function() {
        timer = setTimeout(function() {
            element.children(".mod_units").fadeOut(300);
            element.children(".static_units").fadeIn(300);
        }, 500); 
    });
    

    };

    $(‘.diet_draggable’).each(function() {
    dietDraggable($(this));
    });

    The key is that I’m using both parameters of the jQuery hover function. The second parameter is what happens when you hover off of the element in question. The other key piece is that I’m declaring the timer inside of the function dietDraggable. This ensures that a closure is created for each of the elements and therefore they each have their own timer.

    To see it in action: http://jsfiddle.net/VjHcr/2/

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

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.