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

The Archive Base Latest Questions

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

When I have 2 instances of grid, the jquery does not pick up the

  • 0

When I have 2 instances of grid, the jquery does not pick up the second grid list, but it does for the first. Both grids also work in Opera, Chrome, Safari and Firefox..just not IE.

html:

<ul id = grid>
     <li><div class = "something><div class = hidden>hi</div></div></li>
     <li><div class = "something><div class = hidden>hi</div></div></li>
     <li><div class = "something><div class = hidden>hi</div></div></li>
</ul>

<ul id = grid>
     <li><div class = "something><div class = hidden>hi</div></div></li>
     <li><div class = "something><div class = hidden>hi</div></div></li>
     <li><div class = "something><div class = hidden>hi</div></div></li>
</ul>

css:

.hidden
{
float: left;
display: none;
width: 150px;
height: 150px
}

.something
{
float: left;
width: 150px;
height: 150px
}

jQuery:

<script src="js/jquery.js"></script>
<script>
    $(function() {
        $("#grid li").hover(
            function (e) {
                var index = $('#grid li').index(this);
                $(".hidden").eq(index).show();
                },
            function(e) {
                var index = $('#grid li').index(this);
                $(".hidden").eq(index).hide();
            }
        );
    });
</script>
  • 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-27T11:18:37+00:00Added an answer on May 27, 2026 at 11:18 am

    First you need to make your IDs unique, here is a good resource on how to create valid IDs: What are valid values for the id attribute in HTML?. You JS needs a little work to only select the .hidden elements that are descendants of the grid you are currently hovering over and your class declarations for the .something divs need a closing quote:

    html:

    <ul class = "grid">
         <li><div class = "something"><div class = "hidden">hi</div></div></li>
         <li><div class = "something"><div class = "hidden">hi</div></div></li>
         <li><div class = "something"><div class = "hidden">hi</div></div></li>
    </ul>
    
    <ul class = "grid">
         <li><div class = "something"><div class = "hidden">hi</div></div></li>
         <li><div class = "something"><div class = "hidden">hi</div></div></li>
         <li><div class = "something"><div class = "hidden">hi</div></div></li>
    </ul>
    

    jQuery:

    <script src="js/jquery.js"></script>
    <script>
        $(function() {
            //using the `.children()` function will be faster than $('.grid li')
            $(".grid").children('li').hover(
                function (e) {
    
                    //since $(this) gets used more than once its a good idea to cache it
                    var $this = $(this),
    
                        //to get an index you can just call `.index()` in an element and it will give you that element's index with respect to its siblings
                        index = $this.index();
                    $this.find(".hidden").eq(index).show();
                    },
                function(e) {
                    var $this = $(this),
                        index = $this.index();
                    $this.find(".hidden").eq(index).hide();
                }
            );
        });
    </script>
    

    Docs for .index(): http://api.jquery.com/index

    • 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 settings on multiple instances on a jquery plugin. If
First question. Hope this isn't a repeat. I have an unordered list of thumbnails
I have several instances where that a section of legacy sql statements is based
I have two instances running of same Windows Service. They check the health of
I have two instances of an Address.ascx control in an ASP.NET MVC page. <h1>Shipping
I have similar instances of the same web application running across many domains. I
I have 2 instances of a class that implements the IEnumerable interface. I would
I have two instances of CFMutableBitVector , like so: CFBitVectorRef ref1, ref2; How can
I have several instances of my project running on my server, like so: http://0.0.0.0/one
I have a project where I have multiple instances of an app running, each

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.