- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Make animation occur only on “current” div
When you’re hovering one of the thumbnails the title animates up. What do I need to do to make it animate only on the div that is actually being hovered and not all the ones with the same class?
$(".portfolio-entry").mouseover(function(){
$(".portfolio-heading").animate({
"margin-top": "-30px",
}, 200 );
$(".portfolio-entry").mouseleave(function(){
$(".portfolio-heading").animate({
"margin-top": "5px",
}, 200 );
})
})
I believe if you add , “this” to your selector it will help. so like this:
$(".portfolio-entry").mouseover(function(){
$(".portfolio-heading",this).animate({
"margin-top": "-30px",
}, 200 );
$(".portfolio-entry").mouseleave(function(){
$(".portfolio-heading",this).animate({
"margin-top": "5px",
}, 200 );
})
})
Actually, i think it would be
$(".portfolio-entry").mouseover(function(){
$this.(".portfolio-heading").animate({
"margin-top": "-30px",
}, 200 );
$(".portfolio-entry").mouseleave(function(){
$this.(".portfolio-heading").animate({
"margin-top": "5px",
}, 200 );
})
but maybe I’m incorrect on that.
nearly but:
$(".portfolio-entry").mouseover(function(){
$(this + " .portfolio-heading").animate({
"margin-top": "-30px",
}, 200 );
$(".portfolio-entry").mouseleave(function(){
$(this + " .portfolio-heading").animate({
"margin-top": "5px",
}, 200 );
})
All of the examples worked! Thank you very much! Great forum.
haha awesome :D