How do I build a very simple rich textbox using javascript or jquery to make selected text bold ?
< textarea id="editor">< /textarea>
< input type="button" onclick="bold()" value="Bold selected" />
Here, the text should be appeared to be really bold but not between < b> and < /b> tag. I mean actually like we are editing in wordpress or other rich textbox.
How do I build a very simple rich textbox using javascript or jquery to make selected text bold ?
< textarea id="editor">< /textarea>
< input type="button" onclick="bold()" value="Bold selected" />
Here, the text should be appeared to be really bold but not between < b> and < /b> tag. I mean actually like we are editing in wordpress or other rich textbox.
Share Improve this question edited Jun 24, 2014 at 6:03 Shaunak D 20.6k10 gold badges47 silver badges79 bronze badges asked Jun 24, 2014 at 6:02 user3603684user3603684 611 gold badge2 silver badges8 bronze badges 1-
1
Usually a "rich textbox" is a
div
(orpre
) element withcontenteditable
attribute set totrue
. – Teemu Commented Jun 24, 2014 at 6:11
2 Answers
Reset to default 5The WYSIWYG
editor plugins don't actually use a textarea
.They use an editable div
which makes it possible to show rich text .
These links should help you get started:
HTML contentEditable
WYSIWG Tutorial 1
WYSIWG Tutorial 2
You cannot make just a selected text inside a textarea
to be bold
unless you use some plugins (if exist) or create your own. But instead of inventing the wheel, just use free editors like codemirror or ckeditor