I need a function that traverses #paicasas and leaves the background of all children "casa1, casa2 ...".
I tried to do this but I know it's far from right.
function apagar(){
for(var i in document.getElementById('paicasas')){
document.getElementById('paicasas')[i].style.backgroundColor = "#FFF";
}
}
HTML
<div id="paicasas">
<div id="casa1" onclick="mudarbg(this)"></div>
<div id="casa2" onclick="mudarbg(this)"></div>
<div id="casa3" onclick="mudarbg(this)"></div>
</br>
<div id="casa4" onclick="mudarbg(this)"></div>
<div id="casa5" onclick="mudarbg(this)"></div>
<div id="casa6" onclick="mudarbg(this)"></div>
</br>
<div id="casa7" onclick="mudarbg(this)"></div>
<div id="casa8" onclick="mudarbg(this)"></div>
<div id="casa9" onclick="mudarbg(this)"></div>
<button type="button" onclick="apagar()">Novo</button>
</div>
Enjoying, I really need some stuff that explains about DOM.