新的一年,从一个简单js开始

window.onload = function(){
    var tab = document.createElement("table");
    tab.style.margin = "0 auto";
    tab.style.width = "500px";
    tab.style.height = "500px";
    var tb = document.createElement("tbody");
    tab.appendChild(tb);
    for(var i = 0; i < 100; i++){
        var row = tb.insertRow(tb.rows.length);
        for(var j = 0; j < 100; j++){
            var col = row.insertCell(row.cells.length);
            var a = Math.floor(Math.random() * 255);
            var b = Math.floor(Math.random() * 255);
            var c = Math.floor(Math.random() * 255);
            col.style.backgroundColor = "rgb(" + a + "," + b + "," + c + ")";
        }
    }
    document.body.appendChild(tab);
}