0

I have a text element and I want to get the section that is highlighted selection by mouse only, so lets say user writes 123456798 in the textbox and then select 456 with mouse and I want to get 456, how can I do that ? Does angular library provide me something for it ? Couldnt find in methods. Here is my complete html code for the part.

Actually I entered it but needed to remove first and last <> characters

<input type="text" id="dialpadText" call-from-dialpad="startAudioCall()" 
      ng-model="dialpadText" 
      ng-change="dialpadTextEntered()" 
      placeholder="Enter a name or number" autofocus="" 
      class="ng-valid ng-touched ng-dirty ng-valid-parse ng-modified">
Rasim AVCI
  • 133
  • 2
  • 4
  • 11
  • http://blog.sodhanalibrary.com/2016/10/get-highlightedselected-text-using.html – Robin Dijkhof May 22 '17 at 11:38
  • Possible duplicate of [Javascript get selected text from any textinput/textarea on the page](http://stackoverflow.com/questions/6416020/javascript-get-selected-text-from-any-textinput-textarea-on-the-page) – Daniel Beck May 22 '17 at 11:57

1 Answers1

0

If I understood your question correctly then you wants to get or alert the highlighted value being selected by mouse, right? If that is so, then here is the solution, simply with the help of JavaScript, you can alert the selected value of portion of the text:

<input type="text" onBlur = "getSelectionText()">
<script>
function getSelectionText(){
var selectedText = ""
if (window.getSelection){ // all modern browsers and IE9+
alert(window.getSelection()); //it will alert the selected value
}
}
</script>
Neelam
  • 174
  • 7
  • Actually I do not need answer for this question anymore but my account was banned and I am asked to edit and improve all my previous posts, thanks anyway. – Rasim AVCI Feb 09 '18 at 16:32