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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:58:18+00:00 2026-05-27T16:58:18+00:00

If I want to mouseenter a div, an element will show, then when mouseleave,

  • 0

If I want to mouseenter a div, an element will show, then when mouseleave, element disappears.

I have a click function inside the mouseenter so theres a drop down menu when clicked.

I want the dropdown menu and the element to stay active even when mouseleaves. So I want mouseleaves to not be applicable in this situation, when there’s a click event. User will have to click on the element again or anywhere on the page to make the element and dropdownmenu disappear.

But I want to keep mouseleave function working so if user mouseenters a div, the element will show and they can click on it again.

I currently have something like this, but I just dont know how to make the mouseleave to not be applicable when clicked

$(".div").mouseenter(function(){
        $(".element",this).show();
        $(".element").click(function(){
            $(".dropdown").show();
            return false;
        });
    }).mouseleave(function(){
        $(".element",this).hide();
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<div class='div'>
       <div class='element' style='display:none;'>
          boxed element
       </div>
       <div class='dropdown' style='display:none;'>
          menu
       </div>
    </div>
  • 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-27T16:58:19+00:00Added an answer on May 27, 2026 at 4:58 pm

    You can set a custom attribute for marking the item as clicked. The mouseleave event handler can check the value of this custom attribute before hiding the element.

    i.e. Something like:

    $(".div").mouseenter(function(){
        $(".element",this).show();
        $(".element").click(function(){
            $(".dropdown").show();
    
            // set custom attribute for marking this one as clicked
            $(this).attr('clicked', 'yes'); 
    
            return false;
        });
    }).mouseleave(function(){
    
        // check custom attribute before hiding the element
        if($(this).attr('clicked') != 'yes') {
            $(".element",this).hide();
        }
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Mouseenter of DIV A sets DIV B to show(). What I want is on
I have 3 banners in which I want to have some mouseenter and mouseleave
$(div.test).mouseenter(function() { $(div.innerDiv).fadeIn(slow); }).mouseleave(function() { $(div.innerDiv).fadeOut(slow); }); <div class=test> <div class=innerDiv>1</div> </div> <div class=test>
Want the function to sort the table by HP but if duplicate HPs then
I just want to control a div by toggling a class on click, as
I want to prevent two events from being watched for an element (mouseenter and
I want to know how you keep the hover state of div element active
By default flowplayer tooltip opens on mouseenter,mouseleave events. I want to override it, so
I have a series of div's that I want to highlight with a blue
I have this div that when the mouse enters it, I want it to

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.