Cuando hago clic en el texto en el elemento div, puedo modificar la selección. Sin embargo, esto no es posible con un elemento de enlace. ¿Hay alguna manera de que pueda hacer que esto funcione sin modificar el html?
document.addEventListener('click', click, true) function click(e) { e.preventDefault() } setInterval(() => { let selection = window.getSelection(); selection.modify('extend', 'forward', "documentboundary"); }, 100); <div>text in div tag</div> <a href="">text in a tag</a>¿Esto funciona?
document.addEventListener('click', click, true) function click(e) { e.preventDefault() } setInterval(() => { let selection = window.getSelection(); selection.modify('extend', 'forward', "documentboundary"); }, 100); a { user-select: text; } <div>text in div tag</div> <a href="">text in a tag</a>