Jquery textarea growing with css style

210 views Asked by At

I need to make auto growing textarea. This is what I have: http://jsfiddle.net/EkpVn/1/

CSS:

#contact form textarea {
display: block;
margin: 16px 0 0 0;
padding: 0;
color: #084a94;
font-family: 'Montserrat', sans-serif;
font-size: 20px;
line-height: 22px;
width: 345px;
border: none;
border-bottom: 1px solid #122266;
resize: none;
height: 25px;
}

JS:

$(function() {
   $('.message_autogrow').autogrow();
});

and the final look with autogrowing should look like this:

image

this is not working for me, how to do it right?

2

There are 2 answers

3
metadept On BEST ANSWER

Just need to properly include and use the JQuery Autosize plugin, then call it on your element:

$(function() {
   $('.message_autogrow').autosize();
});

Demo JSFiddle here

0
Hanlet Escaño On

I added the library's code in the jsFiddle, and the method call is actually autoGrow(); with upper case G.

$(function() {
   $('#message').autoGrow();
});

http://jsfiddle.net/EkpVn/2/