【发布时间】:2016-03-09 22:14:58
【问题描述】:
我想在远程 JQuery 验证成功回调完成后显示一个标签。但它似乎没有执行代码。
这是我的代码。
$('#Location').rules("add", {
required: true,
//minlength: 5,
maxlength: 5,
messages: {
required: "Required input",
minlength: jQuery.validator.format("Please, {0} characters are necessary"),
maxlength: jQuery.validator.format("Please, {0} characters are necessary"),
remote: jQuery.validator.format("Could not locate zip code")
},
remote: {
url: "CheckLocation",
type: "post",
data: {
Location: function() {
return $('#Location').val();
},
success: function(data) {
//console.log(data);
$('#locationSuccess').attr('display', ''); // not working
}
}
}
});
<label id="locationSuccess" style="color: green; display: none">ahh, Somewhere</label>
【问题讨论】:
-
使用
$('#locationSuccess').show(); -
它不起作用,因为
display不是attribute;这是一个 CSS 属性。试试.css()而不是.attr()。 -
再次声明,请不要将代码片段功能用于任何不会在此页面中运行的代码。已移除。谢谢。
标签: jquery html css jquery-validate