2

I have been assisted by the remarkable chaps and chapesses in this site to get this far:

$(document).ready(function () {
    $('#join').click(function () {
        $(this).animate({
            height: "320px"
        }, 500, function () {
            $(this).css('overflow', 'visible');
        });
    })
    $('#joinClose').click(function () {
        $('#join').animate({
            height: "40px"
        }, 500, function () {
            $(this).css('overflow', 'hidden');
        });
    });
});

My div grows from it's static height of 40px, to 320 upon click and sets overflow to visible - lovely. however I have added a button to revert back. It sort of works, but as soon as it gets to it's normal size, it grows again! I am pretty new to coding - do I need a stop somewhere?!?!?!

thanks guys.

3
  • 1
    check out www.jsfiddle.net. It's a really handy tool to use here in order to demonstrate what you're trying to do. Commented May 23, 2012 at 19:34
  • This happens because the .click listener of the #join element is triggered for some reason. And you forgot a ";" at line 6 ;) Commented May 23, 2012 at 19:35
  • 2
    Pete, is the #joinClose inside of the #join div? If so that could be part of the problem. You should post your html here as well (or in a JSFiddle). Commented May 23, 2012 at 19:35

1 Answer 1

4

If joinClose is a child of join, you need to stopPropagation on joinClose to prevent it from propagating to join.

$('#joinClose').click(function(e) {
    e.stopPropagation();
    ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.