0

I have the following jQuery

$(".dropdown-menu-1").click(function() {
  $(".submenu-1").toggleClass("visible").removeClass(function() {
    $(".submenu-2").removeClass("visible"),
    $(".submenu-3").removeClass("visible");
  });
}),
$(".dropdown-menu-2").click(function() {
  $(".submenu-2").toggleClass("visible").fadeIn().removeClass(function() {
    $(".submenu-1").removeClass("visible"),
    $(".submenu-3").removeClass("visible");
  });
}),
$(".dropdown-menu-3").click(function() {
  $(".submenu-3").toggleClass("visible").removeClass(function() {
    $(".submenu-1").removeClass("visible"),
    $(".submenu-2").removeClass("visible");
  });
})

Question is, how can I fade those toggleClass-events? As you may can see I tried it with "fadeIn()" but this only results in a bug, so I may be missing here something.

Theres an "possible duplicate" of my question, stating to use jQueryUI, which I did. This hasn't solved my problem. The elements now only needs more time to gets visible, but there is no fading animation.

Does anyone of you is having an idea regarding this?

Thanks!

Atr_Max
  • 269
  • 1
  • 4
  • 20

2 Answers2

0

you can use the animate jquery function ... it is more advanced... but i think you may change the logic of your code... here is the documentation of the jquery function http://api.jquery.com/animate/ you can use the animate function like the below code:

 $("#sliding_div1").animate({ paddingTop: '300px'},200);

the animate function has many properties see the documentation

amir bayan
  • 65
  • 8
0

Do you have specific CSS rules in .visible class ? This should be enough for your needs :

$(".dropdown-menu-1").click(function() {
    $(".visible").fadeOut().removeClass("visible");
    $(".submenu-1").fadeIn().addClass("visible");
});
... 
EdenSource
  • 3,387
  • 16
  • 29