1
$(".item21").click((function() {

    var i = 0;
    return function() {
        $("#submenu").animate({
            marginTop: (++i % 2) ? "+=330px" : "-=330px"
            }, 400);
            return false;
        };
    })());

Where and what can I add so that script will made #submenu fading in or fading out on every second click. I tried something with opacity:0 but I'm stuck. Thanks for help.

Goldie
  • 1,570
  • 5
  • 21
  • 33

3 Answers3

1

This should do the trick: jQuery Toggle

$('#submenu').toggle();

Phil
  • 10,948
  • 17
  • 69
  • 101
  • You won't be able to click something that is display:none – natedavisolds Jun 17 '11 at 16:41
  • I am assuming that the item is apart of the submenu, but that could be wrong. – natedavisolds Jun 17 '11 at 16:52
  • Grrrrrrr I hate when I start in one way and must finish in other :) I made this and now it's working. Thanks $(".item21").toggle( function () { $("#submenu").animate({ marginTop: "+=330px", opacity:1 }, 400); }, function () { $("#submenu").animate({ marginTop: "-=330px", opacity:0 }, 400); } ); – Goldie Jun 17 '11 at 17:07
0

Why not use fadeIn and fadeOut?

Raul Agrait
  • 5,938
  • 6
  • 49
  • 72
0

I would use .css({ visibility: value }) instead of opacity.

natedavisolds
  • 4,305
  • 1
  • 20
  • 25