This time I will share jQuery Plugin and tutorial about Auto Resize Textarea When Typing – auto-resize.js, hope it will help you in programming stack.
A lightweight yet configurable textarea resize jQuery plugin that dynamically adjusts the visible height of textarea elements while typing.
Great for contact & comment form where the textarea element automatically grows and shrinks to fit its content.
How to use it:
1. Insert the auto-resize.js script after loading the latest jQuery library.
1 |
< script src = "/path/to/jquery.slim.min.js" ></ script > |
2 |
< script src = "/path/to/dist/jquery-auto-resize.min.js" ></ script > |
2. Attach the function autoresize
to the existing textarea element and the plugin will take care of the rest.
2 |
$( 'textarea' ).autoresize(); |
3. Customize the min/max visible height (in lines) of the textarea element.
- minRows: defaults to 2
- maxRows: defaults to infinity
3 |
$( 'textarea' ).autoresize(3, 10); |
This awesome jQuery plugin is developed by RifkyLTF. For more Advanced Usages, please check the demo page or visit the official website.