i have a table created by javascript. Every td of this big table contain an other table, now i need to change the background color of every td and with different colors of the big table, just likr this image image example how can i do that? I hope u understand what i want. Of course with javascript only
//Table de multiplication de 1 a 12
function tablede2(n){
var ch = "<table border='0'>",i;
for(i=1;i<=10;i++){
ch = ch + "<tr><td width='30' align='center'>"+n+"</td><td width='30' align='center'>*</td><td width='30' align='center'>"+i+"</td><td width='30' align='center'>=</td><td width='30' align='center'>"+(i*n)+"</td></tr>";
}
return ch +"</table>";
}
function tableMult(){
var ch = "<table border='1' cellspacing='0'>",i, j,n;
n=1;
for(j=1; j<=4; j++){
ch += "<tr>";
for(i=1;i<=3;i++){
ch +="<td>";
ch += tablede2(n);
n++;
ch += "</td>";
}
ch += "</tr>";
}
ch += "</table>";
var elt = document.getElementById("p3");
elt.innerHTML = ch;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Java Script</title>
<script src="exo1_tpJS.js"></script>
</head>
<body>
<button onclick="tableMult()">Table de multiplication de 1 a 12<em> avec innerHTML</em></button>
<div id="p3">Table de multiplication de 2</div>
</body>
</html>