9

If i select a text from a text area i need to know which text is selected, for example "hello world" if i select hello i would like to see hello is selected how can i do this in jquery. and i want to make it bold.

<textarea id="editor" cols="80" rows="20">
   Hello world, This is Me!
</textarea> 
<button onclick="SelectText()">
  Bold
</button>
Ulug'bek
  • 2,652
  • 4
  • 28
  • 56
Naveenbos
  • 2,486
  • 3
  • 32
  • 60

1 Answers1

0

About to make the selected content as bold, you can't do that directly in the textarea but you can do that using editable divs. This plugin could help you: http://mistic100.github.io/jquery-highlighttextarea/

About your comment: "How can i get the all text from a div excluding html tags?" you can use something like this: jQuery('.yourDiv').text();

Rodrigo Techera
  • 251
  • 1
  • 9