function getSelectionHtml() {
const sel = window.getSelection();
if (sel.rangeCount) {
var container = document.createElement("div");
for (var i = 0, len = sel.rangeCount; i < len; ++i) {
container.appendChild(sel.getRangeAt(i).cloneContents());
}
return container.innerHTML;
}
return '';
}
Capatibility:
标签:Major,container,Currently,Content,How,Browsers,Tips,sel From: https://www.cnblogs.com/vgerbot/p/17514716.html