2
I was doing a test that when clicking the button all 'p' should turn red. Someone knows what is wrong?
function test() {
document.querySelectorAll('p').style.color = 'red';
}
<!DOCTYPE html>
<html>
<head>
<title>ola</title>
<meta charset="utf-8">
</head>
<body>
<h1>teste</h1>
<br>
<hr>
<p>ola</p>
<p>oi</p>
<p>qwerty</p>
<button onclick="test()">testes</button>
<script src="teste.js"></script>
</body>
</html>
querySelectorAll
returns an array(set) of elements. It is necessary to use a cycle or modify a particular one– Isac