zoukankan      html  css  js  c++  java
  • textarea高度随内容撑高

    (function($){
          $.fn.autoTextarea = function(options) {
                var defaults={
                  maxHeight:null,
                  minHeight:$(this).height()
                };
                var opts = $.extend({},defaults,options);
                return $(this).each(function() {
                  $(this).height($(this)[0].scrollHeight);
                  $(this).bind("paste cut keydown keyup focus blur",function(){
                    var height,style=this.style;
                    this.style.height = opts.minHeight + 'px';
                    if (this.scrollHeight > opts.minHeight) {
                      if (opts.maxHeight && this.scrollHeight > opts.maxHeight) {
                        height = opts.maxHeight;
                      } else {
                        height = this.scrollHeight;
                      }
                      style.height = height + 'px';
                    }
                  });
                });
              };
            })(jQuery);
        $("#textarea").autoTextarea();

  • 相关阅读:
    SQL的介绍及MySQL的安装
    git中级技能
    git基本用法
    git基本语法
    出租车数据分析
    使用Spark MLlib进行情感分析
    增量式编码器专题
    vue-loader的简单例子
    node爬虫(转)
    fs-extra 文件管理
  • 原文地址:https://www.cnblogs.com/hlyin/p/9541806.html
Copyright © 2011-2022 走看看