Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Jquery .animate

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #32532
    Waffle
    Member

    hey guys!


    $(document).ready(function(){

    $("div.Portpic").click(function(){

    $("div.Portpic").animate({height:280},"fast");

    $("div.Portpic").animate({width:394},"fast");

    });
    });

    This is so div.Portpic goes bigger.. fast.
    I’d like to make it return to its original size on another click!

    But I can’t seem to crack how… Anyone kindly help me out?

    Thanks

    Waffle.

    #48938
    Waffle
    Member

    Also, The jquery messes with my footer below the jquery .animate.

    Any help with that too?

    #48940
    TheDoc
    Member

    I’m afraid I’m still in the jQuery noob category. I’m sure someone will come along soon and give ya some help.

    #48943
    Waffle
    Member

    Haha thanks Doc.

    #48948
    Johnnyb
    Member

    Try googling jquery toggle, or instead use an if statement on click to check the width of the button and then either enlarge it or shrink it.

    John

    #48949

    Johnny is right on, with .animate you can’t actually toggle per-say, but you can create a variable like var portSize = “small”; then use an if statement to grow the div on click, resign the variable to something like “big”, and add another if statement that shrinks the div if var portSize = “big”; then assign it back to “small” at the end, making it toggle-like.

    #48950
    Waffle
    Member

    Oh right, thank you.

    I think jquery toggle sounds better.

    Thanks guys

    #48951

    Making .animate toggle-like is way less confusing than I probably made it sound. Here’s the js for it, change the 100 values to whatever your original dimensions are:


    #48964
    Waffle
    Member

    Cool thanks!

    #48113
    benderz
    Participant

    And why not getting the ‘width’ & and ‘Height’ effect to toggle at the same function ?

     $("div.Portpic").animate({height:280,width:394},"fast");

    &

     $("div.Portpic").animate({height:100,width:100},"fast");
Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.