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

  • Home
  • SEARCH
  • 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 6059597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:43:45+00:00 2026-05-23T08:43:45+00:00

I’m still a noob when it comes to jQuery and I’m literally pulling my

  • 0

I’m still a noob when it comes to jQuery and I’m literally pulling my hair out trying to figure this one out, I’m hoping someone with Javascript experience can point me in the rite direction.

I have a hover function involving a div hide/show event which is fired by hovering li classes involved in a separate mouseenter/mouseleave function with animations.

example

jQuery:

//Right display div swap on hover 
    $('.home, .about, .contact, .services').hover(function(){
        $('#display_'+$(this).attr('class')+':hidden').fadeIn(400); 
    }, function() {
        $('#display_'+$(this).attr('class')).hide()
    });  

//Slide left li classes on mouseenter   
    var sections = ['home','about','contact','services'];
        $.each(sections, function(i,val) {
             var main = $('.' + val);
             var icon = $('#icon_' + val);
         main.mouseenter(function(){ 
                main.stop().animate({left:'115px'}, 600)
                icon.filter(':hidden').fadeIn(600);

        }).mouseleave(function(){
                main.stop().animate({left:'65'}, 600)
                icon.hide();    
    });
    });

//Hidden icons 
    $('#icon_home').hide();
    $('#icon_about').hide();
    $('#icon_contact').hide();
    $('#icon_services').hide(); 
});

I am trying to have mouseleave animations in //Slide left li classes on mouesenter fire under these conditions:

  • If: When hover function is fired by
    hovering any of the other 3 li
    classes
  • else: Same event as mouseenter
    function

So if $('.home') is hovered, it will slide left and the corresponding div on the right will show and stay shown with li class animated left regardless of the mouse’s intent, however, if after $('.home') is hovered and corresponding div appears, the user hovers over say $('.about') , &('.home') will slide back to it’s default CSS position while hiding it’s corresponding div and simultaneously firing $('.about') animations along with showing the $('.about') li class’ corresponding div and so on. This should be continuous (as in a loop).

Any thoughts?

html:

<div id="right_nav">
    <div id='display_home'><img src="images/gallery/home.png" width="605" height="300" /></div>
    <div id='display_about'><img src="images/gallery/about us.png" width="605" height="300" /></div>
    <div id='display_contact'><img src="images/gallery/Contact Us.png" width="605" height="300" /></div>
    <div id='display_services'><img src="images/gallery/Services.png" width="605" height="300" /></div> 
  </div>

  <div id="left_nav">
    <div id="divider_home"><img src="divider.png" width="190" height="2" /></div>
    <div id="divider_about"><img src="divider.png" width="190" height="2" /></div>
    <div id="divider_contact"><img src="divider.png" width="190" height="2" /></div>
    <div id="divider_services"><img src="divider.png" width="190" height="2" /></div>
    <div id="icon_home"><img src="Icons/home.png" width="60" height="60" /></div>
    <div id="icon_about"><img src="Icons/about.png" width="60" height="60" /></div>
    <div id="icon_contact"><img src="Icons/contact.png" width="60" height="60" /></div>
    <div id="icon_services"><img src="Icons/services.png" width="60" height="60" /></div> 

    <div id="thumb">
      <ul>
        <li class="home"><img src="images/gallery/thumb/home.png" width="82" height="23" /></li>
        <li class="about"><img src="images/gallery/thumb/about us.png" width="130" height="24" /></li>
        <li class="contact"><img src="images/gallery/thumb/Contact Us.png" width="150" height="23" /></li>
        <li class="services"><img src="images/gallery/thumb/Services.png" width="113" height="24" /></li>
      </ul>
    </div>   

Suggestions would be greatly appreciated!

Thanks

  • 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-23T08:43:45+00:00Added an answer on May 23, 2026 at 8:43 am

    This should do it:

    var all_displays = $('#right_nav > [id^="display_"]');
    var all_sections = $('#thumb > ul > li');
    var all_icons = $('#left_nav > [id^="icon_"]');
    
    var sections_array = ['home', 'about', 'contact', 'services'];
    
    $.each(sections_array, function(i, sec) {
        var display = all_displays.filter('#display_' + sec);
        var section = all_sections.filter('.' + sec);
        var icon = all_icons.filter('#icon_' + sec);
    
        section.mouseenter(function() {
            if( icon.is(':hidden') ) {
    
                display.fadeIn(400);
                section.stop().animate({ left: '115px' }, 600);
                icon.fadeIn(600);
    
                all_displays.not( display ).hide();
                all_sections.not( section ).stop().animate({ left: '65' }, 600);
                all_icons.not( icon ).hide();
    
            }
    
        });
    });
    
    
    all_icons.hide();
    

    Now that I see what the application is, I changed some of the variable names, and cached each set of displays, sections (the lis), and the associated icons.

    Then in the $.each() I cached in a variable the display, section and icon related to the current item in the sections_array, and assigned a handler to the current section. That handler will continuously reference those 3 related elements.

    After that, it was simply a matter of just assigning only the mouseenter handler, which does 2 things:

    • displays the set of display, section and icon elements it’s referencing,

    • hides all the others by excluding the display, section and icon elements from the entire sets that we previously cached by using the not()[docs] method.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I am trying to loop through a bunch of documents I have to put
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

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.