How to give querySelector in attributes with space?

Asked

Viewed 86 times

1

Ex: I have a <div arvalue="Teste Novo">, and

document.querySelector("div[arvalue='Teste Novo']").style.backgroundColor = "green";

If I take space from the arvalue and put TesteNovo and change the query arvalue='TesteNovo' works.

How can I tell JS that it has a space?

1 answer

2


Something like that?

document.querySelector("div[arvalue='Teste%20Novo']").style.backgroundColor = "green";

Or else:

document.querySelector("div[arvalue='Teste\\ Novo']").style.backgroundColor = "green";

Browser other questions tagged

You are not signed in. Login or sign up in order to post.