jQuery slideDown() animation not working

送分小仙女□ 提交于 2019-12-05 06:42:52

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);
  });
});

You can do it having the content hidden at first and then just showing it with the slideDown function:

HTML

<section class="subscribe">
    <button id="submitBtn" type="submit">Subscribe</button>
    <p>Thanks for your interest!</p>
</section>

CSS

.subscribe p{
    display:none;
}

jQuery

$(function () {
    $("#submitBtn").click(function (event) {
        $(".subscribe p").slideDown({duration: 400});
    });
});

Living example: http://jsfiddle.net/A2mmP/2/

Your modified code

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

Check this demo

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