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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:56:39+00:00 2026-06-01T09:56:39+00:00

I have a problem with a jquery function. My HTML looks like this, I

  • 0

I have a problem with a jquery function. My HTML looks like this, I have several elements like the one below.

<div id="design">
 <span class="flyout_hover">click me
  <div class="flyout">
   show me 1
  </div>
 </span>
</div>

<div id="seo">
 <span class="flyout_hover">click me
  <div class="flyout">
   show me 2
  </div>
 </span>
</div>

<div id="mobil">
 <span class="flyout_hover">click me
  <div class="flyout">
   show me 3
  </div>
 </span>
</div>

EDIT: I have added a new div around each element.

Then I have used this jquery code, which I found here: jQuery toggle – Close all except this

$(".flyout_hover").click(function() {
   var index = $(this).index();
    $('.flyout').eq(index).toggle().siblings('.flyout').hide();
});  

I want to have the same effect as in the example above, like an accordion. But when I click on <.flyout_hover> only the <.flyout> inside the last <.flyout_hover> is shown, no matter what <.flyout_hover> I click.

I guess it has something to do with the index thingy, but I have a hard time finding a solution to it.

Best regards

Vegar

  • 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-01T09:56:40+00:00Added an answer on June 1, 2026 at 9:56 am
    $(".flyout_hover").click(function() {
       var index = $(this).index();
       $('.flyout').eq(index).toggle();
       $(this).siblings().children('.flyout').hide();
    });
    

    EDIT: This is because the .flyout has no siblings inside the containing .flyout_hover element. You have to find the siblings of .flyout_hover and then hide their children.

    Fiddle here: http://jsfiddle.net/3GXk6/5/

    Also, maybe you want to use divs instead of span for .flyout_hover elements?

    EDIT 2: If you only always have one .flyout div inside its parent, you don’t need the index and then you can just use this:

    $(".flyout_hover").click(function() {
       $('.flyout', this).toggle();
       $(this).siblings().children('.flyout').hide();
    });
    

    http://jsfiddle.net/e72hk/

    EDIT 3: When you wrap them in divs as in your edited HTML code, you can just do this instead:

    $(".flyout_hover").click(function() {
        $('.flyout', this).toggle();
        $(this).parent('div').siblings('div').find('.flyout').hide();    
    });
    

    http://jsfiddle.net/e72hk/15/

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

Sidebar

Related Questions

I have a problem with this Jquery function. The the simplifide code looks like:
I have a problem with HTML form and Jquery. The simplified version looks like
I have some jquery that looks like this, $('.career_select .selectitems').click(function(){ var selectedCareer = $(this).attr('title');
I have a function in jquery that looks like this. function interceptFilter(e){ $.ajax({ type:
I have a simple HTML page that looks like this: ...<div id="main"> <a href="#">Click
I have a little problem with some jquery and http://www.mikage.to/jquery/jquery_history_noc.html The function works great,
Never ran into this problem with jQuery before. I have the following: $(document).ready(function() {
I have defined my own function, like this: jQuery.fn.createSelector = function(){ var element =
My html document looks like this: <html> <head> .. load jquery and other stuff
I have an html table that looks like this in a standard HTML 4.01

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.