I have a grid with 9 items, and I want each item to have an opacity of 0.5 initially. When the user hovers over an item, I want it and its contents to have an opacity of 1.0.
Check out the JavaScript code below:
$('.gallery-single').css({ opacity: 0.5 });
$('.gallery-single a').mouseover(function(){
$('.gallery-single-title', this).css('display', 'block');
$('.gallery-single', this).css({ opacity: 1 });
});
$('.gallery-single a').mouseout(function(){
$('.gallery-single-title', this).css('display', 'none');
$('.gallery-single', this).css({ opacity: 0.5 });
});
And here is how the HTML structure looks like:
<div class="gallery-single">
<a href="#" title="">
<div class="gallery-single-title hide">Some text goes here</div>
<div class="gallery-single-img"><img src="http://img.youtube.com/vi/code/0.jpg" width="300" height="200" /></div>
</a>
</div>
All items start with an opacity of 0.5 but do not change when focused. Any ideas on what could be going wrong here?