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

163
Visualizações
How do I run querySelector backwards?

In a document, there are 2 elements with the class name "div._13NKt.copyable-text.selectable-text". (It's web.whatsapp.com)

One on top of the document, one on the bottom of the document.

I would like to querySelect the 2nd element / the element on the bottom.

How could I do this?

Is there an option to do a querySelect backwards?

Here is my code so far:

document.querySelector("div._13NKt.copyable-text.selectable-text").focus();

I am running this command using mobileFX web brower based on Chromium.

I call it like this:

webkit1.Eval("document.querySelector(" & Quote("div._13NKt.copyable-text.selectable-text") & ").focus();")
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Something like this?

const elements = document.querySelectorAll("div._13NKt.copyable-text.selectable-text");
if(elements.length) elements[elements.length - 1].focus();
about 4 years ago · Juan Pablo Isaza Relatório

0

I think you can use document.querySelectorAll("div._13NKt.copyable-text.selectable-text") and then access to the index.

//Capture the elements
let myVar = document.querySelectorAll("div._13NKt.copyable-text.selectable-text");

//Then access to the index, taking into account that the initial index is 0.
console.log(myVar[1])
//Or
var secObject = myVar[1];
about 4 years ago · Juan Pablo Isaza Relatório
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