显示成功消息onsubmit函数时,淡入淡出无法工作:

这是我的Javascript:

<script>
popUpForm = function() {
    jQuery('#successMessage').text("Successfully submitted !").fadeIn("slow")
    jQuery('#successMessage').css("display", "block")

    setTimeout(function() {
        jQuery('#successMessage').fadeOut()
        jQuery('#successMessage').css("display", "none")
    }, 5000);
}
</script>  And Here is my message block div: <div th:id = "successMessage"  class="alert-box success"></div>

最佳答案

不确定是否使用以下代码。

var auto_info = setInterval(function() {
        $("#successMessage").text("Successfully submitted !").fadeIn("successMessage");

    $("#successMessage").trigger('updatelayout');

    setTimeout(function() {
        jQuery('#successMessage').fadeOut();
    }, 5000);

   });

09-17 21:43