Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda