title: How to Select text by range from the current word to end of that Sentence(.) in a paragraph
body: <p>I need to implement the <strong>selection of text by range</strong> on click from current word to end of that sentence in the paragraph.</p>
  
  <p>For example:</p>
  
  <blockquote>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the...</p>
  </blockquote>
  
  <p>is a paragraph. When I click on dummy the selection is to be done from dummy to industry. The below code enables me to select the full paragraph on single click.</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;&lt;/script&gt;
      &lt;style type="text/css"&gt;
         p {
         font-family: monospace;
         font-size: 1.5em;
         }    
      &lt;/style&gt;
     &lt;/head&gt;
  
     &lt;body&gt;
  
        &lt;div id="autoselect"&gt;
           &lt;p&gt;Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
      when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, 
      remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing 
      software like Aldus PageMaker including versions of Lorem Ipsum.&lt;/p&gt;
       &lt;/div&gt;
  
   &lt;script type="text/javascript"&gt;
  
    function SelectText(element) {
      var doc = document,
          text = doc.getElementById(element),
          range,
          selection;
      if (doc.body.createTextRange) {
          range = document.body.createTextRange();
          range.moveToElementText(text);
          range.select();
      } else if (window.getSelection) {
          selection = window.getSelection();        
          range = document.createRange();
          range.selectNodeContents(text);
          selection.removeAllRanges();
          selection.addRange(range);
      }
  }
  $(function() {
  
      $('p').click(function () {
          SelectText('autoselect');
      });
  
  }); 
  
  &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>