$('textarea').on('input', function() {
var scrollHeight = parseInt($(this).prop('scrollHeight'));
$(this).height(scrollHeight);
$(this).prev('.Content').outerHeight(300 - $(this).outerHeight());
});
$(".Content").scrollTop($('.Content').height())
.OuterDiv
{
width:200px;
height:300px;
border:1px solid #000;
position:relative;
}
.Content
{
width:200px;
max-height:250px;
background-color:grey;
overflow:auto;
}
.text
{
resize:none;
position:absolute;
bottom:0;
left:0;
width:194px;
height:45px;
max-height:145px;
background-color:rgba(250, 120, 30,1);
font-size:16px;
font-family:Arial;
overflow:auto;
word-wrap:break-word;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="OuterDiv">
<div class="Content">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<textarea class="text" placeholder="Write some text..."></textarea>
</div>
Good morning,
Is there a way to keep the scroll bar at the bottom while typing in the textarea (the textarea expands upwards as text is added)? The scrollbar starts at the bottom after refreshing the page, but doesn't stay at the bottom when adding text.