简体   繁体   中英

Jquery animate function not working with 'this' selector

I have a really simple function but I have been banging my head against a wall with implementing it. For some reason when I have 'this' selector in the function it doesn't work at all but works without.

I need 'this' to apply the function to the selected div only when hovered.

Here is the jsfiddle i have been testing it on, I have tried everything I can think of but had no luck.

http://jsfiddle.net/aGVNk/89/

You are trying to select an element by class within specified context (specified element), and this is what jQuery does for you. However, you should expect that jQuery cannot find your galleryheader within the image, as it is not a child of the image.

Your header is contained withing div with class gallery-grid , which you should use in this case.

It would look like this: http://jsfiddle.net/NqXHF/3/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM