title: Highlight selected text with jquery
body: <p>When a user selects any text in my html page I want to add a custom style (like <code>color:red;</code>) to it. This will act as a highlighting tool similar to what you can see in some applications for reading pdf files. </p>
  
  <p>To do this I declare <code>highlight()</code> function that gets the text which is selected, plus its position.</p>
  
  <pre><code>function highlight(text, x, y) {
          alert(text+'***'+x+'***'+y)
          window.getSelection().removeAllRanges();
      }
  </code></pre>
  
  <p>jsfiddle link edited</p>
  
  <p><a href="http://jsfiddle.net/prince4prodigy/7xpJH/" rel="nofollow">jsFiddle</a></p>