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>
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
.hiddenelements that are descendants of the grid you are currently hovering over and your class declarations for the.somethingdivs need a closing quote:html:
jQuery:
Docs for
.index(): http://api.jquery.com/index