$(document).on('mouseup',function(){ console.log(window.getSelection().toString()); });
Supplement: Mark the selected content
$(document).on('mouseup',function(e){ let a = document.createElement("span"); a.setAttribute("class","wrap"); window.getSelection().getRangeAt(0).surroundContents(a); });
<style> span.wrap{background:goldenrod;} </style>