如何在jquery中进行验证时更改div的高度



如何在jquery 中进行验证时更改div的高度

这个div包含错误消息。div应该随时更新其高度消息已更新

  errorPlacement : function(error, element) {
        $('#error_container').show();
        error.appendTo($('#error_container'));
        $('#error_container').append("<br>");
    },

我试着申请

     $("#error_container").attr({ 
          height: "auto"
        });

但没有为这个找到合适的位置

像这样设置

$("#error_container").css('height', 'auto');

这样尝试:

$("#error_container").attr("style","height:auto");

或者像这样使用.css()

$("#error_container").css('height', 'auto');

试试这个。我还将你添加的
改为底部填充,这样你就可以很容易地删除它。

errorPlacement : function(error, element) {
  $('#error_container').show();
  error.appendTo($('#error_container'));
  $('#error_container').css('padding-bottom', '20px');
  $("#error_container").css('height', 'auto');
},

如果你需要撤销填充,你可以做:

  $('#error_container').css('padding-bottom', '0');

最新更新