HTML element does not fade in using jquery

泪湿孤枕 提交于 2019-12-30 11:26:49

问题


I have a small web project as you can see here: http://seegermattijs.be/pickone/ When you insert two items, the pick one button should fade in. Unfortunately it does not fade. I use the following code:

$('.bigBtn').fadeIn('slow');

and in the begininning I make .bigBtn invisible:

$('.bigBtn').hide()

What am I doing wrong?


回答1:


The CSS transitions that you have applied to every element on the page (very beginning of your css/main.css):

* {
    transition: all .1s linear;
    -webkit-transition: all .1s linear;
    -moz-transition: all .1s linear;
    -o-transition: all .1s linear;
}

are clashing with the jQuery fade animation.

Remove the CSS transitions from your button using something like:

.bigBtn {
    transition: none;
    -webkit-transition: none;
    -moz-transition: none;
    -o-transition: none;
}

(Or better still, only apply them where you want them in the first place).

Your .fadeIn('slow') will then work.




回答2:


$('.add').on('click',function(){
    var items = $('.items > h2').length;
    if(items >= 2) {
       $('.bigBtn').fadeIn('slow');
    }
});


来源:https://stackoverflow.com/questions/20470872/html-element-does-not-fade-in-using-jquery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!