jQuery slideDown()动画不起作用 [英] jQuery slideDown() animation not working

查看:162
本文介绍了jQuery slideDown()动画不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让jQuery的 slideDown()动画起作用,但在我的情况下,应该的文本向下滑动出现 我如何使它与动画一起出现?

我也尝试手动指定速度,但最终结果是相同。



HTML:

  < section class =subscribe> 
< button id =submitBtntype =submit>订阅< / button>
< p>< / p>
< / section>

JavaScript:

  $(function(){
$(#submitBtn)。click(function(event){
$(。subscribe p)。 (感谢您的兴趣!)。slideDown({
duration:4000
});
});
});

JSFiddle: http://jsfiddle.net/ahmadka/A2mmP/

当您输入文本并尝试将其滑下时,code> p 元素已经显示。所以不需要动画。

  $(function(){
$(#submitBtn)。click函数(事件){
$(。subscribe p)。hide()。html(谢谢你的兴趣!)。slideDown(4000);
});
} );


I'm trying to get jQuery's slideDown() animation to work, but in my case the text that should slide down, just appears .. How do I make it appear with the animation in place too ?

I tried manually specifying the speed too, but end result was the same.

HTML:

<section class="subscribe">
    <button id="submitBtn" type="submit">Subscribe</button>
    <p></p>
</section>

JavaScript:

$(function () {
    $("#submitBtn").click(function (event) {
        $(".subscribe p").html("Thanks for your interest!").slideDown({
                        duration: 4000
                    });
    });
});

JSFiddle: http://jsfiddle.net/ahmadka/A2mmP/

解决方案

Your p element is already displayed when you enter the text and try to slide it down. So no animation is needed.

$(function () {
  $("#submitBtn").click(function (event) {
    $(".subscribe p").hide().html("Thanks for your interest!").slideDown(4000);
  });
});

这篇关于jQuery slideDown()动画不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆