0

I have

<div id="862976/image.png">

and I'm trying to identify the element by:

document.querySelector('#862976/image.png')

but it tells me that the selector is invalid, probably because an id can't contain the characters (# / .) I have tried to escape the characters with CSS.escape:

document.querySelector(CSS.escape('#862976/image.png'))

But the result is null

How do I identify the element, without changing its id?

Dima White
  • 11
  • 1

1 Answers1

0

Since the ID is invalid, if you absolutely cannot change the ID, then you can use getElementById or search by attribute instead:

document.getElementById('862976/image.png');
document.querySelector('[id="862976/image.png"]');
rid
  • 57,636
  • 30
  • 143
  • 185