Advertisement
Virajsinh

Textarea Auto Resize using JQuery

Sep 19th, 2020
1,383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.34 KB | None | 0 0
  1. <style type="text/css">
  2. textarea {
  3.     resize: none;
  4.     overflow: hidden;
  5.     min-height: 50px;
  6.     max-height: 100px;
  7. }
  8. </style>
  9.  
  10. <textarea oninput="auto_grow(this)"></textarea>
  11.  
  12. <script type="text/javascript">
  13. function auto_grow(element) {
  14.     element.style.height = "5px";
  15.     element.style.height = (element.scrollHeight)+"px";
  16. }
  17. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement