0

Is it possible to make a reference to a html element by a string (preferably a query selector), i made a mouse tracker which should add the target element, but if you reload the page it should still be able to find the same element. i tried going with event.composedPath() and event.target, But both dont seem to work

the string will be saved in a json file

6
  • 2
    Are you asking how to get a query selector string from an existing element? Commented Mar 28, 2024 at 19:29
  • 1
    If the element has an ID, you can just use '#' + element.id Commented Mar 28, 2024 at 19:29
  • thats what im asking yes, but none of the elements has a class or id, the string can be any element getting hovered or clicked on Commented Mar 28, 2024 at 19:32
  • its basically an empty div or label or any other tag Commented Mar 28, 2024 at 19:33
  • 1
    See the linked question. Commented Mar 28, 2024 at 19:34

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.