1

I've been developing a text editor for a while, and I've tried my hardest to find a way so that if you select a few words or a string and press a button to change color, that specific string selected will get changed to that color All I'll provide is my text box: <textarea rows="2" cols="100" name="message" ng-model="message" id="info"></textarea> I have buttons to change the whole text, but I want only the string someone selects. Thanks :)

Sir Binary
  • 11
  • 2
  • you need to select the text and wrap the text in a span or something else. Maybe this link help you to start: http://stackoverflow.com/questions/5379120/get-the-highlighted-selected-text – Sysix Apr 29 '17 at 19:16
  • Do you want to select the text and do operation on selected text? May be this could help: http://jsfiddle.net/JasonMore/gWZfb/ – Nitesh Apr 29 '17 at 19:19
  • The first comment, that was helpful but I need to know how to **change** that selected text. The second one is useful, but only displays text, doesn't take action on the element itself – Sir Binary Apr 29 '17 at 19:39
  • You can refer to this link https://forum.jquery.com/topic/how-to-get-selected-text-in-a-textarea-and-style-it. – Kartik Chauhan Apr 29 '17 at 19:49
  • I've seen that, but it's only for making things bold, not adding style. My CSS file contains a few special IDs for the element and making all bold elements be one thing would not help. – Sir Binary Apr 29 '17 at 21:30

0 Answers0