0

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!

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
roozbubu
  • 1,106
  • 4
  • 14
  • 30

1 Answers1

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