开发者

make the selected text bold in textarea

开发者 https://www.devze.com 2023-03-22 12:08 出处:网络
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

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 T开发者_运维技巧extArea. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消