双击页面中的词语获得文本
<html>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<body>
<script language="JavaScript">
$(document).ready(function() {
$("#text").dblclick(function() {
alert(window.getSelection().toString());
});
});
</script>
<p>双击单词获得单词文本</p>
<p id="text">Highlight a part of this text, then click button below</p>
</body>
</html>
效果图