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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:53:40+00:00 2026-05-29T11:53:40+00:00

OK, I am missing something fundamental here I am sure! But for the life

  • 0

OK, I am missing something fundamental here I am sure! But for the life of me can not work it out.

Scenario

It’s a simple hide show menu;

// Setup hover
        var fadeDuration = 200;
        var setDelay;
        $level1Item.hover(function () {
            $(this).addClass('hover').find('.level-2').fadeIn(fadeDuration);
        }, function () {
            $(this).removeClass('hover').find('.level-2').fadeOut(fadeDuration);
        });

And it works fine… but the drop down is rather LARGE and is irritating when it pops up all be it very sexily when you mouse moves from top to bottom of screen.

So I want to set a timeout and clear it on mouse out…

// Setup hover
        var fadeDuration = 200;
        var setDelay;
        $level1Item.hover(function () {
            setDelay = setTimeout("$(this).addClass('hover').find('.level-2').fadeIn(200)", 500);
            //$(this).addClass('hover').find('.level-2').fadeIn(fadeDuration);
        }, function () {
            clearTimeout(setDelay);
            $(this).removeClass('hover').find('.level-2').fadeOut(fadeDuration);
        });

ABSOLUTELY NOTHING HAPPENS!! I have tried alerts in the timeout function and they work… originally the variable fadeDuration was undefined but a number stops the console error.

  • 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-29T11:53:42+00:00Added an answer on May 29, 2026 at 11:53 am

    You can’t use this in the setTimeout-code, since this depends on the context. So when the timeout fires, the this is a different this… bad English, but hopefully it makes sense.

    Also, avoid using strings in timers; use functions instead. While you can use a string, which is then evaluated as JavaScript, it’s generally bad form compared to simply wrapping the same code in a function

    var fadeDuration = 200;
    var setDelay;
    $level1Item.hover(function () {
        var element = $(this);
        setDelay = setTimeout(function() {
            element.addClass('hover').find('.level-2').fadeIn(fadeDuration);
        }, 500);
    }, function () {
        clearTimeout(setDelay);
        $(this).removeClass('hover').find('.level-2').fadeOut(fadeDuration);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm probably missing out on something fundamental here but it seems rather tricky and
i'm missing something fundamental here. i have a very simple custom class that draws
Probably missing something completely obvious here, but here goes. I'm starting out with Spring
Multiple posts but I'm still stuck...I'm missing something fundamental here. I have a form
I'm sure this is ordinary Rails behavior, and I'm missing something fundamental, but what
I'm missing something fundamental here. I have a table view with each cell displaying
OK, I'm feeling like this should be easy but am obviously missing something fundamental
Must be missing something really obvious here but how do you change the size
I may be missing something, but I'm sure that I've checked everything, I forked
I am completely lost. I think I am definitely missing something fundamental here. Everybody

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.