is there any way to get highlighted or selected text data from a user using php or javascript? I am building a text editor and need to use a callback function to bold/highlight/underline/etc selected text. thanks!
Asked
Active
Viewed 171 times
0
-
possible duplicate of [get selected text's html in div](http://stackoverflow.com/questions/5669448/get-selected-texts-html-in-div) – Marc B Oct 17 '11 at 21:11
-
Please learn the difference between Java and JavaScript. – Andrew Thompson Oct 17 '11 at 21:12
-
iv been using google but every time i searched php and nothing came up. and i now the difference, I accidently tagged java. – roozbubu Oct 17 '11 at 21:34
1 Answers
1
for <textarea>
:
txtarea.textLength;
txtarea.selectionStart;
txtarea.selectionEnd;
for elements like <div>
etc. check this tutorial http://www.webreference.com/js/column12/crossbrowser.html
you may like to check this powerful and simple javascript text editor - TinyCME

Peter
- 16,453
- 8
- 51
- 77
-
thanks! this helped, appreciate you actually answering and not being a smart*** like two of those guys^^. I know this was probably a really noobish question. – roozbubu Oct 17 '11 at 21:35