You would want to set the binding when the document loads, not every time the mouse hovers over the image. Also, I would create a class so that you can initialize the hover on each item
$(document).ready(function() {
$(".image-hover-class").hover(function(){
$(this).find('img').fadeTo("slow", 1.0);
},function(){
$(this).find('img').fadeTo("slow", 0.6);
});
});
For the link, you would do something like this:
<a class="image-hover-class" href="?tg=photos&photo=$imageid" \>
<img src='users/$ptgid/images/$iimg' width='100' height='100'/>
</a>
If you want to do the hover on the div
, you could do this instead (but I recommend doing the hover on the <a>
tag):
$(document).ready(function() {
$(".image-hover-class").hover(function(){
$(this).find('a img').fadeTo("slow", 1.0);
},function(){
$(this).find('a img').fadeTo("slow", 0.6);
});
});
For the div, you would do something like this:
<div class="image-hover-class">
<a href="?tg=photos&photo=$imageid" \>
<img src='users/$ptgid/images/$iimg' width='100' height='100'/>
</a>
</div>