
Originally Posted by
azoomer
I would love to hear from somebody how it could be improved. It is not the smartest way trying to select the parents siblings children, would have been easier with a cousin selector !!
Code:
jQuery(function($){
var ims = $('.imggall img').hover(function(){
ims.not($(this)).stop().fadeTo(600, 0.4);
}, function(){
ims.not($(this)).stop().fadeTo(600, 1);
});
});
This is a another way to do $(document).ready() and works even when jQuery is in noConflict mode. The highlight class appeared to serve nothing in this set up. The .end() function is only useful if you want to revert the selector chain to what it was before your last change, there is a change in the selector chain where you used it, but you don't do anything with the restored collection it selects, so there is no need for it. The delay() function delays what follows it in the queue. I'm unclear if you really have a queue situation here or not. In any case, 80 ms is unnoticeable to the human eye and doesn't appear to be required by the code, you have stop()'s to prevent colliding of the fade animation effects, that should be enough.
The markup could be more concise. You could change it to:
HTML Code:
<div class="imggall">
<div><img src="images/1.jpg" width="300" height="199" /></div>
<div><img src="images/2.jpg" width="300" height="199" /></div>
<div><img src="images/3.jpg" width="300" height="199" /></div>
<div><img src="images/4.jpg" width="300" height="199" /></div>
<div><img src="images/5.jpg" width="300" height="199" /></div>
<div><img src="images/6.jpg" width="300" height="199" /></div>
</div>
Everything would work as before, as long as you change your style selector here (add the red part):
Code:
.imggall div {
width:auto;
height:auto;
background-color:#040404;
display:block;
float:left;
margin:3px;
border:3px solid #FFFFFF;
-moz-box-shadow:2px 2px 6px #B0B0B0;
-webkit-box-shadow:2px 2px 6px #B0B0B0;
}
With a bit more tweaking we could probably get it to work for multiple .imggall on a page with the effect constrained to only the .imggall that was being hovered at that particular moment.
Bookmarks