How to give querySelector in attributes with space?

1

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

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

If I take out the space of arvalue and put TesteNovo and change the query arvalue='TesteNovo' it works.

How can I tell JS that I have a space?

    
asked by anonymous 11.07.2016 / 21:36

1 answer

2

Something like this?

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

Or else:

document.querySelector("div[arvalue='Teste\ Novo']").style.backgroundColor = "green";
    
11.07.2016 / 21:50