I have these divs (notes) where i need each one to have a different ID each and i have managed to figure out how to give them their own unique ID, but now i dont know how to get them. I can do by using the manually function where i write the ID myself but thats not a good way. So what im struggling with is getting the id 'rect' which i increment with 1 eahc time i create a new one. So rect0, rect1, rect2 and so on. But how do i get them without using: this function 100times?
function update(jscolor) {
document.getElementById('rect0').style.backgroundColor = "#" + jscolor;
document.getElementById('rect1').style.backgroundColor = "#" + jscolor;
document.getElementById('rect2').style.backgroundColor = "#" + jscolor;
document.getElementById('rect3').style.backgroundColor = "#" + jscolor;
document.getElementById('rect4').style.backgroundColor = "#" + jscolor;
document.getElementById('rect5').style.backgroundColor = "#" + jscolor;
document.getElementById('rect6').style.backgroundColor = "#" + jscolor;
document.getElementById('rect7').style.backgroundColor = "#" + jscolor;
document.getElementById('rect8').style.backgroundColor = "#" + jscolor;
document.getElementById('rect9').style.backgroundColor = "#" + jscolor;
document.getElementById('rect10').style.backgroundColor = "#" + jscolor;
document.getElementById('rect11').style.backgroundColor = "#" + jscolor;
document.getElementById('rect12').style.backgroundColor = "#" + jscolor;
document.getElementById('rect13').style.backgroundColor = "#" + jscolor;
document.getElementById('rect14').style.backgroundColor = "#" + jscolor;
document.getElementById('rect15').style.backgroundColor = "#" + jscolor;
document.getElementById('rect16').style.backgroundColor = "#" + jscolor;
document.getElementById('rect17').style.backgroundColor = "#" + jscolor;
document.getElementById('rect18').style.backgroundColor = "#" + jscolor;
document.getElementById('rect19').style.backgroundColor = "#" + jscolor;
}
I've tried where i get the rect and then increment like using ++, but it didnt work, so i hope anyone know a efficient way.