最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to build simple rich textbox? - Stack Overflow

programmeradmin0浏览0评论

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 (or pre) element with contenteditable attribute set to true. – Teemu Commented Jun 24, 2014 at 6:11
Add a ment  | 

2 Answers 2

Reset to default 5

The 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

发布评论

评论列表(0)

  1. 暂无评论