How to have a textarea to keep scrolled to the bottom when updated

前端 未结 5 1921
礼貌的吻别
礼貌的吻别 2020-12-03 03:06

My problem is a bit off the cuff here, so I\'ll try to explain this best I can.

I have a text area, having css of #object{overflow:hidden;resize:none;}.

5条回答
  •  春和景丽
    2020-12-03 03:22

    Generic JQuery Plugin

    Here a generic jquery plugin for scrollBottom of any element:

    $.fn.scrollBottom = function() {
      return $(this).scrollTop($(this)[0].scrollHeight);
    };
    

    usage:

    $("#logfile").val( $("#logfile").val() + "this is new line test\n" ).scrollBottom();
    

提交回复
热议问题