Javascript examples for jQuery:Form Textarea
Textarea expand its width while the user is typing
<html> <head> <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> </head> //w ww. ja va2 s. c o m <body> <textarea class="my" type="textarea" data-minwidth="100"></textarea> <script> $(".my").keypress(function() { var newWidth = ($('.my').val().length)*10; if(newWidth > $(".my").data('minwidth')){ $('.my').width(newWidth); } }); </script> </body> </html>