tags:

views:

380

answers:

2

Please, help to rewrite this jQuery function:

$(".gallery dt a img").fadeTo("fast", .7);
$(".gallery dt a").hover(function () {
    $(this).fadeTo("fast", 1)
},
function () {
    $(this).fadeTo("fast", .7)
});

Here is a html:

<dl class="gallery">
    <dt><a href="#"><img /></a></dt>
    <dd><a href="#">text</a></dd>
</dl>

Image appears (opacity: 1) when I hover a link in <dt> tag, how can I change this, to make image appear when I hover a links in both <dt> and <dd> tags?

Nobody knows?

A: 

You can use:

$('.gallery-small dl:children a')
seth
thanks, but this solution doesn't work
Mike
A: 

I think seth has the right selector for the hover, but in the hover I think you'd need a reference to the image itself instead of using $(this). Maybe something like:

var img = $(".gallery-small dt a img");
img.fadeTo("fast", .7);
$('.gallery-small dl:children a').hover(function() {
    img.fadeTo("fast", 1)
},
function() {
    img.fadeTo("fast", .7)
});
ironsam
doesn't work :(
Mike
Do you know where it is breaking? Perhaps it is the selectors? Do you have a parent of <dl> with a class name of `gallery-small`? What does this get you: `alert($(".gallery-small").length);`?
ironsam
it gives "1"
Mike
Do you get any opacity effects to work at all? Or is it just when hovering that it doesn't work?
ironsam
its seems to give nothing, no opacity and no effects. You can try it yourself
Mike
That's why I'm a bit confused. I was able to get it working in FF 3.5 with the code I have above. What type of image (png, jpg, etc) are you using and what browser?
ironsam