Forums

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

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #31262
    OlafG
    Member

    http://dev.olafg.com/mc/work/

    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 );
    })
    })
    #65760
    jsweazy
    Member

    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 );
    })
    })

    #65652
    dhechler
    Member

    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.

    #65586
    Rob MacKay
    Participant

    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 );
    })
    #65555
    OlafG
    Member

    All of the examples worked! Thank you very much! Great forum.

    #65438
    Rob MacKay
    Participant

    haha awesome :D

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.