我的 html 中隐藏了一些输入字段,如下所示:
<input type="text" class="hidden" />
<button class="hidden">click me!</button>
通过 jquery,我以这种方式显示此类控件:
$('input').removeClass('hidden');
这工作得很好,但我想在元素变得可见时添加淡入淡出效果。可以通过 css 做到这一点吗?所以当元素可见时自动出现淡入淡出效果?
最佳答案
$('#show').click(function(){
$('.hidden').fadeIn(1000).removeClass('hidden');
})
.hidden{
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" class="hidden" />
<button class="hidden">click me!</button>
<button id='show'>CLICK TO SHOW</button>
关于javascript - 当元素可见时添加过渡效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41922217/