jquery - 使用 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");
}
})
})
解决方案
您可能需要show()
该元素,因为它已从 DOM 中隐藏
if(resp=="false")
{
//#chkpwd is span id
$('#chkpwd').show().html('<font color="red">Current Password is Incorrect</font>');
$('#chkpwd').fadeOut(3000);
}
推荐阅读
- python - 用 Python 替换一些带有特殊字符的 HTML 标签
- html - jQuery scrollTop 在移动设备上滚动折叠的导航栏
- jira - 获取授权码 OAuth 后 JIRA 访问令牌生成 url。我的网址面临授权错误
- javascript - 使用丰富的降价编辑器反应
- c++ - C++:递归匹配参数类型与类模板类型
- python - 使用 ligthttpd 服务器为 python wsgi 应用程序存储私钥
- c# - C# GET 请求没有值
- node.js - 在 Node js 中使用 Crypto 进行加密会抛出错误
- javascript - 按每列搜索和显示表格元素
- dns - 两个 Squarespace 网站可以属于同一个子域,用斜线