I'm trying to change all divs of one color to another one. It works with document.querySelector() but not with querySelectorAll. I would like to change all of them. Here's my code:
<html>
<head>
<script >
var v;
var v1;
function link(){
 v1=document.querySelector('[style*="background:black;"]');
 v1.style.backgroundColor = "red";
    v=document.querySelectorAll('[style*="background:black;"]');
 v.style.backgroundColor = "red";
}
</script>
</head>
<body>
<div style="background:black; height:100px; width:100px;"></div>
<div style="background:blue; height:100px; width:100px;"></div>
<div style="background:black; height:100px; width:100px;"></div>
<div style="background:black; height:100px; width:100px;"></div>
<div style="background:blue; height:100px; width:100px;"></div>
<button onclick="link()" style="height:20px; width:50px;">Click </button>
</body>
</html>Any ideas on what could I do? Thanks!
 
     
     
    