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

167
Vistas
Is there a way to get a website element by the visible text?

I am just starting to learn some basics of javascript related to html. I would like to know is there a way to select the html element by its visible text?

For example: If I would like to click the “Interesting” button on the stackfoverflow page I can find the element by querySelector.

stack overflow html page code sample:

<a class="youarehere is-selected flex--item s-btn s-btn__muted s-btn__outlined" 
    href="?tab=interesting" 
    data-nav-xhref="" 
    title="Questions that may be of interest to you based on your history and tag preference" 
    data-value="interesting" data-shortcut="">
        Interesting
</a>

one way of locate the html element:

document.querySelector("a[class='youarehere is-selected flex--item s-btn s-btn__muted s-btn__outlined']").click()

I know there might be some other ways to locate the element, but am I able to locate the element by the visable text “Interesting”? Thanks if anyone knows how.

stack overflow page html sample image down below.

stack overflow html sample

about 4 years ago · Juan Pablo Isaza
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