I need to be able to render some HTML tags inside a textarea (namely <strong>, <i>, <u>, <a>) but textareas only interpret their content as text. Is there an easy way of doing it without relying on external libraries/plugins (I'm using jQuery)? If not, do you know of any jQuery plugin I could use to do this?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
With an editable div you can use the method
document.execCommand
(more details) to easily provide the support for the tags you specified and for some other functionality..This is possible with
<textarea>
the only thing you need to do is use Summernote WYSIWYG editorit interprets HTML tags inside a textarea (namely
<strong>
,<i>
,<u>
,<a>
)try this example on JSFiddle
Edit by Jeffrey Crowder - Web Developer/Windows programmer
I added a JS fiddle of the code.
I have the same problem but in reverse, and the following solution. I want to put html from a div in a textarea (so I can edit some reactions on my website; I want to have the textarea in the same location.)
To put the content of this div in a textarea I use:
This is not possible to do with a
textarea
. What you are looking for is an content editable div, which is very easily done:jsFiddle
Since you only said render, yes you can. You could do something along the lines of this:
textarea
will render html! Besides the flashing when resizing, inability to directly use classes and having to make sure that the div in thesvg
has the same format as thetextarea
for the caret to align correctly, it's works!