简体   繁体   中英

make the selected text bold in textarea

I have got two TextAreas and i want to use one toolbar. The toolbar should contain buttons for making the text in the textbox bold, italic, align to the left and right, add bullet points etc.. What I don't get is: how can I make the selected text in the textarea bold ? I was using an iFrame before for writing text and used the iframe.contentDocument.execCommand() for that purpose. But I think we can not use the execCommand() for a TextArea. To make it simple, I am just trying to make something like a TextArea which is identical to the TextArea when we post questions on stackoverflow, with a toolbar above it! But I don't know how to do operations on the text!

You cannot use textarea, because textarea can only contain character data, that is unstructured text . Thus, all the contents of textarea have the same style.

That's why CKEditor, TinyMCE etc. use iframes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM