Question: As an example that we have

Name : Abdul Naeem

if we select the Naeem from above so to get Abdul From it.......

is it possible to get the left side words of the selected words

i tried but i have not found this..... can any body help me out of this problem.

i found some tips where it only get the selected words but i need the words on its left side

[Get the Highlighted/Selected text](https://stackoverflow.com/questions/5379120/get-the-highlighted-selected-text)

for example lets consider if an object weighs 30 N. now i want to select the 30, and get the word weighs from it ?? how can i do it in javascript –

Answer: 
**note just tested it in \*\*CHROME**, it will display all words to left to "SELECTED" Word

You need to modify it a little bit according to your need, just try

```
//console.log(window.getSelection().focusNode.data);

var textSelected = window.getSelection().toString();

var fulltext = window.getSelection().focusNode.data;

console.log(fulltext.substr(0,fulltext.length-textSelected.length));

```
```
<!DOCTYPE html>
<html>
<body>

<p>Click the button to display the array values after the split.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var str = "Abdul Naeem";
    var res = str.split(" ");
    for(i=0;i<res.length;i++)
    {

    alert(res[i]);
    }
    //document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>

```