认为这是一个简单的问题,但我对 Web 开发人员很陌生,所以我很抱歉 :) -> 在 onSelect 事件中,我如何获取所选内容的内容?有没有办法修改选中的文本,比如高亮显示?
这是我到目前为止:
<textarea id="text">
Text to be highlighted
</textarea>
Run Code Online (Sandbox Code Playgroud)
在js中:
let text_selection = document.getElementById("text");
text_selection.addEventListener("select", highlightText);
function highlightText(){
alert('hello');
}
Run Code Online (Sandbox Code Playgroud)