2016-04-22 56 views
0

我有用於自動調整textarea作爲用戶鍵入的jQuery代碼。有沒有辦法讓它停在屏幕底部?如何停止超出屏幕長度的文字區域?

<html> 
<head> 
    <title>Page Title</title> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"> </script> 
</head> 
<style> 
    .modalTextArea{ 
     overflow: hidden; 
     z-index: 1; 
    } 
</style> 
<body> 
    <div class="modal-content">   
     <textarea class='modalTextArea' rows = 2 style='width: 100%'></textarea> 
    </div> 
    <script src = 'js/script.js'></script> 
</body> 
</html> 
$('.modalTextArea').on('keyup', function(e){ 
    $(this).css('height', 'auto'); 
    $(this).height(this.scrollHeight + 10); 
}); 
+1

僅供參考,您的'