리자

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

· 18년 전 · 2743
<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,824
18년 전 조회 2,141
18년 전 조회 2,321
18년 전 조회 2,872
18년 전 조회 2,964
18년 전 조회 4,130
18년 전 조회 6,117
18년 전 조회 2,056
18년 전 조회 2,191
18년 전 조회 1,897
18년 전 조회 1,658
18년 전 조회 2,632
18년 전 조회 1,689
18년 전 조회 1,561
18년 전 조회 4,736
18년 전 조회 1,789
18년 전 조회 1,842
18년 전 조회 1,849
18년 전 조회 1,977
18년 전 조회 3,628
18년 전 조회 1,655
18년 전 조회 1,526
18년 전 조회 1,357
18년 전 조회 1,859
18년 전 조회 1,909
18년 전 조회 3,651
18년 전 조회 1,981
18년 전 조회 3,114
18년 전 조회 4,741
18년 전 조회 2,872
18년 전 조회 8,051
18년 전 조회 4,062
18년 전 조회 2,744
18년 전 조회 1,523
18년 전 조회 2,626
18년 전 조회 5,044
18년 전 조회 5,220
18년 전 조회 2,096
18년 전 조회 4,359
18년 전 조회 4,097
18년 전 조회 4,151
18년 전 조회 2,274
18년 전 조회 4,192
18년 전 조회 2,176
18년 전 조회 3,286
18년 전 조회 4,921
18년 전 조회 1,956
18년 전 조회 3,414
18년 전 조회 1,645
18년 전 조회 2,744
18년 전 조회 1,671
18년 전 조회 2,713
18년 전 조회 2,555
18년 전 조회 1,559
18년 전 조회 1,502
18년 전 조회 1,743
18년 전 조회 2,247
18년 전 조회 2,017
18년 전 조회 2,387
18년 전 조회 4,915
18년 전 조회 1,822
18년 전 조회 1,261
18년 전 조회 1,383
18년 전 조회 1,341
18년 전 조회 1,084
18년 전 조회 1,073
18년 전 조회 1,407
18년 전 조회 1,370
18년 전 조회 2,353
18년 전 조회 1,234
18년 전 조회 1,612
18년 전 조회 2,090
18년 전 조회 1,276
18년 전 조회 2,828
18년 전 조회 1,279
18년 전 조회 1,653
18년 전 조회 1,500
18년 전 조회 1,457
18년 전 조회 1,237
18년 전 조회 1,078
18년 전 조회 1,665
18년 전 조회 1,103
18년 전 조회 3,621
18년 전 조회 1,716
18년 전 조회 1,792
18년 전 조회 1,115
18년 전 조회 1,853
18년 전 조회 1,099
18년 전 조회 1,172
18년 전 조회 1,020
18년 전 조회 1,008
18년 전 조회 1,097
18년 전 조회 2,582
18년 전 조회 1,548
18년 전 조회 1,634
18년 전 조회 1,202
18년 전 조회 1,872
18년 전 조회 1,519
18년 전 조회 1,482
18년 전 조회 1,712
🐛 버그신고