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

186
Views
Detect the order of 2 Elements or Nodes in DOM tree using JavaScript

I get anchorNode and focusNode of the window selection.

const { anchorNode, focusNode } = window.getSelection();

How can I determine which one of these is before another in DOM? In other words, I need a solution to detect the position of this element within the DOM tree.

For example, in strings we can use indexOf method to find the index of a word or substring. I need a method like document.indexOfNode(node).

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