How to get selected text in a textarea and style it?

How to get selected text in a textarea and style it?

Hi,

I'd like to know how to obtain the selected text inside a textarea and style it. So I can create my own inline text editor. So if I press a button while I have something highlighted it will turn bold.

Thank you