Browse Source

评论框高度适应

guohh 5 years ago
parent
commit
7becb7ea37
2 changed files with 17 additions and 2 deletions
  1. 16 0
      2020/x-3/biz/js/common/tool.js
  2. 1 2
      2020/x-3/task-detail.html

+ 16 - 0
2020/x-3/biz/js/common/tool.js

10
    return this;
10
    return this;
11
  };
11
  };
12
12
13
  // textarea 高度自适应
14
  $.fn.autoHeight = function(){
15
    function autoHeight(elem){
16
      elem.style.height = 'auto';
17
      elem.scrollTop = 0; //防抖动
18
      elem.style.height = elem.scrollHeight + 'px';
19
    }
20
    this.each(function(){
21
      autoHeight(this);
22
      $(this).on('keyup', function(){
23
        autoHeight(this);
24
      });
25
    });
26
  }
27
13
  $(function () {
28
  $(function () {
29
    $('textarea[autoHeight]').autoHeight();
14
30
15
    // 搜索框交互部分
31
    // 搜索框交互部分
16
    $(".common-search").each(function (i, obj) {
32
    $(".common-search").each(function (i, obj) {

+ 1 - 2
2020/x-3/task-detail.html

103
    </div>
103
    </div>
104
  </div>
104
  </div>
105
105
106
107
  <div class="ipu-flex-col task-note-input-body">
106
  <div class="ipu-flex-col task-note-input-body">
108
    <div class="task-note-input-wrap ipu-fn-bd-t">
107
    <div class="task-note-input-wrap ipu-fn-bd-t">
109
      <textarea class="task-note-input" placeholder="输入评论内容,@通知其他人"></textarea>
108
      <textarea autoHeight class="task-note-input" placeholder="输入评论内容,@通知其他人" rows="1"></textarea>
110
    </div>
109
    </div>
111
  </div>
110
  </div>
112
</div>
111
</div>