Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

display div inside text area

I'm looking to display html in a text area. Is it possible to display a <div> containing form elements inside a <textarea> using javascript or jquery?

like image 821
Michael Insalaco Avatar asked Jan 23 '12 14:01

Michael Insalaco


2 Answers

You cannot put div in textarea but sometimes you need to do so. Good news is that you can do it in other way by using contenteditable property of elements. Like

 <div contenteditable="true" style="min-height:50px; width:300px;" id="txtDiv">
 </div>

This Div will behave exactly like a Textarea but you can append anything you want. And remember when you want to grab data from inside it in jquery

 var ContentofDiv = $('#txtDiv').html();

Now you can append childs just like others.

like image 72
Airy Avatar answered Sep 19 '22 05:09

Airy


You cannot place HTML elements inside a text area, only text content.

like image 27
JaredMcAteer Avatar answered Sep 18 '22 05:09

JaredMcAteer