首页 > 解决方案 > 使用 fadeOut() 后,消息将不再显示

问题描述

输入错误密码后,消息会显示,但会在一定时间后淡出,如果再次输入错误密码,消息将不再显示。每次输入错误密码时,我应该如何获取输入错误密码的消息?

$(document).ready(function(){
    $("#new_pwd").click(function(){
        var current_pwd=$("#current_pwd").val();
        $.ajax({
            type:"get",
            url:"../admin/check-pwd",
            data:{current_pwd:current_pwd},
            success:function(resp){
                if(resp=="false")
                {
                    //#chkpwd is span id
                    $('#chkpwd').html('<font color="red">Current Password is Incorrect</font>');
                    $('#chkpwd').fadeOut(3000);
                }
                else if(resp=="true")
                {
                    $('#chkpwd').html('<font color="green">Current Password is Correct</font>');
                }
            },
            error:function()
            {
                alert("Error");
            }
            
        })
    })	

标签: jquery

解决方案


您可能需要show()该元素,因为它已从 DOM 中隐藏

if(resp=="false")
{
    //#chkpwd is span id
    $('#chkpwd').show().html('<font color="red">Current Password is Incorrect</font>');
    $('#chkpwd').fadeOut(3000);
}

推荐阅读