Is it possible to retrive selected text outside textbox?
I had seen solutions to get text from input forms and textareas, similar to this:
http://laboratorium.0xab.cd/jquery/fieldselection/0.2.3-test/test.html
but can this aplied on HTML text (inside div element)?
For example, I want user to be able to bold selected text which is not in textarea.
Yes, it’s possible. IE and other browsers have rather different mechanisms for dealing with selections. If you simply want the selected text, the following will do it:
To address your specific question, you can use
document.execCommand("bold", null, false);to make the current selection bold. In non-IE browsers you have to temporarily put the document into edit mode first though: