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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:24:06+00:00 2026-06-09T08:24:06+00:00

I have a simple hover animation; i seperated mouseenter and mouseleave functions to define

  • 0

I have a simple hover animation; i seperated mouseenter and mouseleave functions to define a contidion on mouseleave. If that cocontidion is true; disable mouseleave function but i cant get this condition work, javascript ignores my condition and run mouseleave function.

Here is jsFiddle.

jQuery:

$('.bigBox').mouseenter(function() {
    $('.trigger').stop().animate({'left':'-50px'},222);
    $('.bigBox').stop().animate({'left':'-1px'},222);
});


var holdCondition = $('#hold').hasClass('selected');
//tried to disable mouseleave here but didnt work

if ( !holdCondition ) {//if #hold has not class selected
    $('.bigBox').mouseleave(function() {
        $('.trigger').stop().animate({'left':'-1px'},222);
        $('.bigBox').stop().animate({'left':'-111px'},222);
    });
}


$('.option').click(function(){
    $('.option').removeClass('selected');
    $(this).addClass('selected');
});

html:

<div class="bigBox">
   <span class="trigger">X</span>

   <span class="option selected">A</span>
   <span class="option">B</span>
   <span id="hold" class="option">Hold</span>
</div>

css:

.bigBox {
    position:fixed; top:10%; width:100px; height: 20px; 
    left:-111px;  border:1px solid #000; padding-left:5px;
}
.trigger { 
    position:fixed; top:10%; width:20px; height: 20px; 
    left:-1px; border:1px solid #000; text-align:right; padding-right:5px;
}
.option { margin:0 5px; cursor:pointer; }
.selected { color:#f00; }

​

  • 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-06-09T08:24:07+00:00Added an answer on June 9, 2026 at 8:24 am

    your holdCondition will only run once instead you have to check it every .mouseleave().
    try this.

    Here is jsFiddle.

       $('.bigBox').mouseleave(function() {
            var holdCondition = $('#hold').hasClass('selected');
    
            if ( !holdCondition ) {//if #hold has not class selected
              $('.trigger').stop().animate({'left':'-1px'},222);
              $('.bigBox').stop().animate({'left':'-111px'},222);
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple hover function that appears to work fine in everything
I have a simple jQuery hover animation: jQuery(function($) { $('.category').hover(function(){ $(this).find('.banner').fadeIn(); },function(){ $(this).find('.banner').fadeOut(400); });
I have a simple search box that it hidden until hover(over) and hides again
It's strange. I have an animation that start when i .hover on a DIV.
I have a simple gallery style link setup using image swap on hover that
I have this simple code: $('.featureItems li').hover( function(){ $(this).addClass('hover') }, function(){ $(this).removeClass('hover') } )
I have a simple drop-down menu that is controlled using the following script: $(document).ready(function
I have a simple JQuery animation that reduces the opacity of a div on
on my master page, I have referenced jquery file. I am doing simple hover
so I have a simple problem. I have a hover background image change effect,

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.