3

i´d like to fadeIn a submenu and chance the position at the same time.

Like the cool Coda-Tooltip (http://panic.com/coda/) over "download".

My code just do the fade this time:

$(document).ready(function(){
    $('#access').hover(function () {
        $(this).children('ul').fadeIn();
         $(this).children('ul')...position();

    }, function () {
        $(this).children('ul').fadeOut('slow');
        $(this).children('ul')...position();
    });
});

Thanks Ingo

Now I do this:

$(document).ready(function(){
$('#access').hover(function () {
    $(this).children('ul').stop().animate({opacity:1, paddingTop:'10px'}, 400);

}, function () {
    $(this).children('ul').stop().animate({opacity:0, paddingTop:'0px'}, 300);
});

});

Fadein and the padding works great. But not by fadeOut. What´s my mistake?

ogni
  • 327
  • 7
  • 17

2 Answers2

2

the best i can think of is to make use of jQuery swichClass . It uses animate implicitly.

check out this fiddle example : http://jsfiddle.net/xyDwV/1/

CSS:

.before{
    background-color : red;
    height : 400px;
    width :200px;
    opacity : 1;
}
.after{
    background-color : blue;
    height : 200px;
    width : 400px;
    opacity : 0.5;
}

jquery:

$(document).ready(function(){
  $('#mydiv').hover(function () {
        $(this).switchClass('before','after',500);
    }, function () {
        $(this).switchClass('after','before',500);
  });
});
dku.rajkumar
  • 18,414
  • 7
  • 41
  • 58
0

simply roll your own animation with animate(). and never forget to use stop to cancel the currently running animation first.

$(this).find('ul').stop().animate({opacity:1, top:'...', left:'...'});
roman
  • 11,143
  • 1
  • 31
  • 42