title: Detect if text is highlighted on mouse up jQuery
body: <p>How can I detect if any text is highlighted using jQuery.</p>
  
  <p>I tried:</p>
  
  <pre><code>$(document).mouseup(function(){
      if(typeof window.getSelection!="undefined"){
          console.log("text highlighted");
      }
  });
  </code></pre>
  
  <p>but it dind't work, the <code>console.log()</code> fired each time the mouse click was released, even if there wasn't any highlighted..</p>