标签不显示在JQuery远程成功回调中

时间:2016-03-09 22:14:59

标签: jquery html css jquery-validate

我希望在远程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>

1 个答案:

答案 0 :(得分:1)

使用jQuery .show()方法

$('#locationSuccess').show();

或.css()

$('#locationSuccess').css('display', '');