I was doing a test that when clicking the button all 'p' should turn red. Does anyone know what's 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>