Skip to content Skip to sidebar Skip to footer

Can I Add More After "this" In Jquery?

I'm working on a script that fades in and out both an image and a div I have set behind the image when you hover over the image. I'm having two problems: The fades on the image an

Solution 1:

You've got the general idea. One thing you should know about a selector is that you are able to define a second argument as the scope of the selector, i.e.

$("selectorString", scopeObject)

In your case, make the second argument $(this).closest("li"). It will find the list item containing your image and select .info descendants of that container:

$(".info", $(this).closest("li")).fadeIn(1000);

Solution 2:

Change $(".info") to $(this).find(".info") and all will be sweet.

Post a Comment for "Can I Add More After "this" In Jquery?"