리자

JS 이용해서 동적으로 테이블 생성

· 18년 전 · 2732
<script>
    function erase(o)
    {
        alert(document.getElementById(o));
        document.getElementById(o).removeChild(document.getElementById(o).getElementsByTagName('tr')[0]);
    }

    function make()
    {
        alert("우하하");
        var tbl     = document.getElementById("tbl");
        var tblBody = document.getElementById("tblBody");

        // creating all cells
        for (var j = 0; j < 2; j++) {
            // creates a table row
            var row = document.createElement("tr");

            for (var i = 0; i < 2; i++) {
                // Create a <td> element and a text node, make the text
                // node the contents of the <td>, and put the <td> at
                // the end of the table row
                var cell = document.createElement("td");
                var cellText = document.createTextNode("cell is row "+j+", column "+i);
                cell.appendChild(cellText);
                row.appendChild(cell);
            }

            // add the row to the end of the table body
            tblBody.appendChild(row);
        }
        tbl.setAttribute("border", "2");
    }
</script>

<input type="button" value="start" onclick="make()">
<input type="button" value="delete" onclick="erase('tblBody');">

<table id="tbl">
    <tbody id="tblBody">


    </tbody>
</table>
 
꼭 tbody 태그를 넣어야 한다는거 유의!!
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

프로그램

+
제목 글쓴이 날짜 조회
18년 전 조회 2,816
18년 전 조회 2,129
18년 전 조회 2,308
18년 전 조회 2,859
18년 전 조회 2,952
18년 전 조회 4,117
18년 전 조회 6,107
18년 전 조회 2,043
18년 전 조회 2,176
18년 전 조회 1,886
18년 전 조회 1,645
18년 전 조회 2,621
18년 전 조회 1,681
18년 전 조회 1,548
18년 전 조회 4,727
18년 전 조회 1,777
18년 전 조회 1,828
18년 전 조회 1,836
18년 전 조회 1,964
18년 전 조회 3,618
18년 전 조회 1,642
18년 전 조회 1,517
18년 전 조회 1,346
18년 전 조회 1,851
18년 전 조회 1,897
18년 전 조회 3,642
18년 전 조회 1,969
18년 전 조회 3,104
18년 전 조회 4,727
18년 전 조회 2,858
18년 전 조회 8,041
18년 전 조회 4,048
18년 전 조회 2,732
18년 전 조회 1,514
18년 전 조회 2,613
18년 전 조회 5,029
18년 전 조회 5,209
18년 전 조회 2,084
18년 전 조회 4,346
18년 전 조회 4,089
18년 전 조회 4,142
18년 전 조회 2,264
18년 전 조회 4,184
18년 전 조회 2,165
18년 전 조회 3,275
18년 전 조회 4,908
18년 전 조회 1,946
18년 전 조회 3,402
18년 전 조회 1,635
18년 전 조회 2,733
18년 전 조회 1,659
18년 전 조회 2,705
18년 전 조회 2,545
18년 전 조회 1,547
18년 전 조회 1,491
18년 전 조회 1,732
18년 전 조회 2,234
18년 전 조회 2,005
18년 전 조회 2,375
18년 전 조회 4,906
18년 전 조회 1,815
18년 전 조회 1,250
18년 전 조회 1,370
18년 전 조회 1,330
18년 전 조회 1,072
18년 전 조회 1,063
18년 전 조회 1,398
18년 전 조회 1,354
18년 전 조회 2,344
18년 전 조회 1,222
18년 전 조회 1,599
18년 전 조회 2,079
18년 전 조회 1,264
18년 전 조회 2,817
18년 전 조회 1,263
18년 전 조회 1,641
18년 전 조회 1,491
18년 전 조회 1,443
18년 전 조회 1,226
18년 전 조회 1,068
18년 전 조회 1,652
18년 전 조회 1,093
18년 전 조회 3,610
18년 전 조회 1,704
18년 전 조회 1,779
18년 전 조회 1,104
18년 전 조회 1,844
18년 전 조회 1,090
18년 전 조회 1,161
18년 전 조회 1,008
18년 전 조회 995
18년 전 조회 1,083
18년 전 조회 2,566
18년 전 조회 1,534
18년 전 조회 1,624
18년 전 조회 1,193
18년 전 조회 1,861
18년 전 조회 1,507
18년 전 조회 1,472
18년 전 조회 1,701
🐛 버그신고