最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Make bootstrap div fade out when adding 'hidden' class - Stack Overflow

programmeradmin0浏览0评论

I am using Bootstrap for css and I need help in fading out a div when the class 'hidden' is toggled.

My site structure is pretty simple: there are 3 main container divs: search, wait and show. Essentially, show is the lowest positioned one, wait is on top of show and search is at the very top.

All I need is for search to fade out over 3 seconds when this Jquery event is fired:

    $('.search').toggleClass('hidden');

I don't want it to just instantly disappear. Same with the wait div. I have tried using

    $(".searchBar").fadeOut("slow", function() {
        $('.searchBar').toggleClass('hidden');
    });

But it doesn't work. The fadeout/fadein don't seem to have any visible effect. Since the hidden class is already in bootstrap, I do not want to create another custom one; there's got to be a way to acplish this.

I am using Bootstrap for css and I need help in fading out a div when the class 'hidden' is toggled.

My site structure is pretty simple: there are 3 main container divs: search, wait and show. Essentially, show is the lowest positioned one, wait is on top of show and search is at the very top.

All I need is for search to fade out over 3 seconds when this Jquery event is fired:

    $('.search').toggleClass('hidden');

I don't want it to just instantly disappear. Same with the wait div. I have tried using

    $(".searchBar").fadeOut("slow", function() {
        $('.searchBar').toggleClass('hidden');
    });

But it doesn't work. The fadeout/fadein don't seem to have any visible effect. Since the hidden class is already in bootstrap, I do not want to create another custom one; there's got to be a way to acplish this.

Share Improve this question asked Sep 8, 2014 at 12:15 DarshanDarshan 1,0113 gold badges16 silver badges29 bronze badges 1
  • Add opacity: 0; and a CSS transition to .hidden class. – Kyle Commented Sep 8, 2014 at 12:15
Add a ment  | 

2 Answers 2

Reset to default 2

Bootstrap hidden class is:

.hidden {
  display: none;
  visibility: hidden;
} 

You can easily achieve this:

$('.searchBar').toggle( "slow");

Use something like this:

$(".searchBar").fadeOut("slow", function() {
    $('.searchBar').addClass('hidden').show(0);
});
发布评论

评论列表(0)

  1. 暂无评论