您好,我希望我具有获取所选文本段落的功能。
这是获取所选文本的当前段落的功能
function getSelected() {
var userSelection;
if (window.getSelection) {
selection = window.getSelection();
} else if (document.selection) {
selection = document.selection.createRange();
}
var parent = selection.anchorNode;
parent = parent.parentNode;
alert(parent.innerHTML);
}
如何在网页中获取所选文本的下一个上一段。如果我有功能来获取上面的当前段落。(我想使用 nextSibling 但我不知道在上面的代码中实现它)你能帮我吗?
-谢谢你-