【发布时间】:2019-12-04 19:58:36
【问题描述】:
我正在尝试使用 window.getSelection 获取选定的文本。但它不起作用。我没有收到任何错误。
HTML
<span (mouseup)="showSelectedText()" id="descriptionText" class="val descriptionText" [innerHTML]="descriptionText"></span>
JS
showSelectedText(oField) {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
console.log('text: ' + text)
this.selectedText = text;
}
}
【问题讨论】: