Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
Modify user selection on click event on an <a> element?

When I click on the text in the div element i am able to modify the selection. However this is not possible with a link element. Is there a way I can make this work without modifying the 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>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Does this work?

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>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda