zoukankan      html  css  js  c++  java
  • textarea自动加高代码

    (function($){
    $.fn.extend({
    textareaAutoHeight: function (options) {
    this._options = {
    minHeight: 0,
    maxHeight: 1000
    }

    this.init = function () {
    for (var p in options) {
    this._options[p] = options[p];
    }
    if (this._options.minHeight == 0) {
    this._options.minHeight=parseFloat($(this).height());
    }
    for (var p in this._options) {
    if ($(this).attr(p) == null) {
    $(this).attr(p, this._options[p]);
    }
    }
    $(this).keyup(this.resetHeight).change(this.resetHeight)
    .focus(this.resetHeight);
    }
    this.resetHeight = function () {
    var _minHeight = parseFloat($(this).attr("minHeight"));
    var _maxHeight = parseFloat($(this).attr("maxHeight"));

    if ($.support.leadingWhitespace) {
    $(this).height(0);
    }
    var h = parseFloat(this.scrollHeight);
    h = h < _minHeight ? _minHeight :
    h > _maxHeight ? _maxHeight : h;
    $(this).height(h).scrollTop(h);
    if (h >= _maxHeight) {
    $(this).css("overflow-y", "scroll");
    }
    else {
    $(this).css("overflow-y", "hidden");
    }
    }
    this.init();
    }
    });
    })(jQuery)

  • 相关阅读:
    素材收集
    网站返回503
    uva 1048 最短路的建图 (巧,精品)
    hdu5188 01 背包
    hdu 5187 快速幂 + 快速乘 值得学习
    差分约束
    uva11090 Bellman-Ford 运用
    hdu 5185 动态规划 分析降低复杂度
    hdu5184 数论证明
    HDU5183 hash 表
  • 原文地址:https://www.cnblogs.com/anyaran/p/3478072.html
Copyright © 2011-2022 走看看