Looks good!

If you want to make the code a bit more efficient, you can tweak it a bit and cache $('Form2'), since you use it a couple times.

Here is a slightly altered version (using slideUp/slideDown because I think they're prettier):

$("#Button1").click(
        function() {
                var $Form2 = $("#Form2");     
                if ($Form2.is(':visible')) {
                        $Form2.slideUp('fast', function() {
                                $('#Form1').slideDown('fast');
                        });
                } else {
                        $Form2.slideDown('fast');
        }

        // Don't follow the click
        return false;
});



--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Jul 14, 2007, at 2:18 PM, navvywavvy wrote:


Okay - first of all, thanks for you help guys - got the gears turning
until I figured out how to do it. It's pretty simple actually, and I
figured I'd post it here in case anyone else comes across this
problem:

// Show Form1
$("#Button1").click(
        function() {
                var $Form2 = $("#Form2:visible");
                if ($Form2.length) {
                        $("#Form2").hide(
                                function() {
                                        $("#Form1").show();
                                });
                } else {
                        $("#Form2").show();
                }

                // Don't follow the click
                return false;
        });

... And then the reverse for the other button. Cool!


On Jul 13, 5:09 pm, "Glen Lipka" <[EMAIL PROTECTED]> wrote:
jQuery uses a concept of "callbacks". These basically say, "Dont do the
next step until the animation is finished."

This demo is one I made the other day.http://www.commadot.com/ jquery/nextrow/toggle.htm#

  $("a#controller").click( function() {

    $("div.box:visible").slideUp("slow",function(){
      //alert("Animation Done.");
      $("div.box").load("text.htm",
        function() {
          $("div.box").pause(200).slideDown("medium");
        }
      );
    });

  } );

Notice how on the SlideUp function, I have a callback right after it. This
makes it wait.
Additionally, I used the pause plugin to wait an additional 200ms, because
0ms, seemed too abrubt.

Based on your example, I think this would work for you.

Glen

On 7/13/07, navvywavvy <[EMAIL PROTECTED]> wrote:



Okay, here is an example:

http://cotworld.com/jquery-test/


Reply via email to