Popup on table row text highlight/selection - Javascript jQuery

Javascript examples for jQuery:Selector

Description

Popup on table row text highlight/selection

Demo Code

ResultView the demo in separate window

<html lang="en">
 <body> 
  <table> 
   <tbody> 
    <tr> 
     <td>SOME TEXT</td> 
    </tr> // w  ww  .  j a  v a 2s  . co  m
   </tbody> 
  </table> 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 
  <script>
      $('table').on('mouseup', function(){
  var selectedText = window.getSelection().toString();
  if (selectedText) {
    console.log('Some text was selected');
  }
})
   
      </script>  
 </body>
</html>

Related Tutorials