JavaScript 获取用户选择的文本
const getSelectedText = () => window.getSelection().toString();
getSelectedText();
JQuery实例:
$(function(){
const getSelectedText = () => window.getSelection().toString();
$('#button').click(function () {
console.log(getSelectedText());
});
});
本文来自博客园,作者:重庆熊猫,转载请注明原文链接:https://www.cnblogs.com/cqpanda/p/17059326.html