Question

I have a couple of divs displayed in order and I want when the user rolls over each div show the content in a slide up animation. I have done the most part but I'm struggling to grasp how to make the animation happen when you roll over the right div. Currently when I rollover one div its showing all three of the animated content.

Any help would be great.

code is:

$(".collection-content").hover(function () {
  $(".collection-info").slideToggle("fast");
});

I know it has something to do with a foreach statement but I just can't get there.

thanks

Was it helpful?

Solution

Change this

$(".collection-content").hover(function () {
    $(".collection-info").slideToggle("fast");
});

To this

$(".collection-content").hover(function () {
    $(this).find(".collection-info").slideToggle("fast");
});

OTHER TIPS

Change this

$(".collection-content").hover(function () {
    $(".collection-info").slideToggle("fast");
});

To this

$(".collection-content").hover(function () {
    $(".collection-info", this).slideToggle("fast");
});

Try this please:

if you are looking for children you could use .next possibly.

Flick me you html and we can help out more, :)

$(".collection-content").hover(function () {
  $(this).find(".collection-info").slideToggle("fast");
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top