如何在Javascript中使用这样的div元素制作拼图表?

时间:2014-01-09 12:22:52

标签: javascript html css

我想知道如何在javascript中使用div元素制作拼图表? 我必须使用div。

function puzzle() {
    var puzzleTable = document.createElement("div");
    puzzleTable.style.width = "400px";
    puzzleTable.style.height = "400px";
    puzzleTable.style.marginTop = "200px";
    puzzleTable.style.marginLeft = "450px";
    puzzleTable.style.border="1px solid black";
    document.body.appendChild(puzzleTable);
    var cell=[];
    for (var i = 0; i < 4; i++) {
        for (var j = 0; j < 4; j++) {
            var cells = document.createElement("div");
            cells.style.width = "25px";
            cells.style.height = "25px";
            cells.style.marginTop = "2px";
            cells.style.border = "1px solid black";
            document.body.appendChild(cells);
            cell[i,j]=new cell[i,j,cell.value()];
        }
    }
}