Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a resizable textarea?

Tags:

How does Stackoverflow implement the resizable textarea?

Is that something they rolled themselves or is it a publicly available component that I can easily attach to textareas on my sites?

I found this question and it doesn't quite do what I want.

autosizing-textarea

That talks more about automatically resizing textareas whereas I want the little grab-area that you can drag up and down.

like image 687
Mark Biek Avatar asked Sep 29 '08 16:09

Mark Biek


People also ask

How do I automatically resize textarea?

It can be achieved by using JavaScript and jQuery. Method 1: Using JavaScript: To change the height, a new function is created which changes the style property of the textarea. The height of the textarea is first set to auto. This value makes the browser set the height of an element automatically.

Can a textarea be resized?

In many browsers, <textarea> elements are resizable by default. You may override this behavior with the resize property.

How do you make a textbox resizable?

Resize a text box Select the text box. Select one of the handles and drag until the text box is the size you want.

How do I make textarea draggable?

What I meant was that when you create the text area in myFunction() you can add the draggable=true attribute to it and specify the relevant ondragstart and ondragend logic for those relevant areas.


2 Answers

StackOverflow uses a jQuery plugin to accomplish this: TextAreaResizer.

It's easy enough to verify this - just pull the JS files from the site.

Historical note: when this answer was originally written, WMD and TextAreaResizer were two separate plugins, neither one of which was authored by the SO Dev Team (see also: micahwittman's answer). Also, the JavaScript for the site was quite easy to read... None of these are strictly true anymore, but TextAreaResizer still works just fine.

like image 68
Shog9 Avatar answered Oct 05 '22 19:10

Shog9


I needed a similar functionality recently. Its called Autogrow and it is a Plugin of the amazing jQuery library

like image 25
Roman Ganz Avatar answered Oct 05 '22 21:10

Roman Ganz