Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!