리자

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

· 18년 전 · 2740
<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,823
18년 전 조회 2,139
18년 전 조회 2,318
18년 전 조회 2,870
18년 전 조회 2,963
18년 전 조회 4,126
18년 전 조회 6,116
18년 전 조회 2,054
18년 전 조회 2,187
18년 전 조회 1,895
18년 전 조회 1,655
18년 전 조회 2,631
18년 전 조회 1,688
18년 전 조회 1,559
18년 전 조회 4,733
18년 전 조회 1,787
18년 전 조회 1,839
18년 전 조회 1,848
18년 전 조회 1,972
18년 전 조회 3,627
18년 전 조회 1,651
18년 전 조회 1,524
18년 전 조회 1,356
18년 전 조회 1,857
18년 전 조회 1,905
18년 전 조회 3,650
18년 전 조회 1,978
18년 전 조회 3,114
18년 전 조회 4,737
18년 전 조회 2,867
18년 전 조회 8,049
18년 전 조회 4,060
18년 전 조회 2,740
18년 전 조회 1,520
18년 전 조회 2,625
18년 전 조회 5,039
18년 전 조회 5,219
18년 전 조회 2,095
18년 전 조회 4,355
18년 전 조회 4,096
18년 전 조회 4,149
18년 전 조회 2,272
18년 전 조회 4,192
18년 전 조회 2,174
18년 전 조회 3,284
18년 전 조회 4,918
18년 전 조회 1,954
18년 전 조회 3,411
18년 전 조회 1,643
18년 전 조회 2,741
18년 전 조회 1,670
18년 전 조회 2,712
18년 전 조회 2,550
18년 전 조회 1,555
18년 전 조회 1,500
18년 전 조회 1,740
18년 전 조회 2,244
18년 전 조회 2,014
18년 전 조회 2,384
18년 전 조회 4,913
18년 전 조회 1,821
18년 전 조회 1,261
18년 전 조회 1,379
18년 전 조회 1,338
18년 전 조회 1,081
18년 전 조회 1,070
18년 전 조회 1,406
18년 전 조회 1,365
18년 전 조회 2,352
18년 전 조회 1,232
18년 전 조회 1,609
18년 전 조회 2,089
18년 전 조회 1,272
18년 전 조회 2,826
18년 전 조회 1,275
18년 전 조회 1,650
18년 전 조회 1,499
18년 전 조회 1,454
18년 전 조회 1,234
18년 전 조회 1,077
18년 전 조회 1,661
18년 전 조회 1,102
18년 전 조회 3,620
18년 전 조회 1,713
18년 전 조회 1,789
18년 전 조회 1,113
18년 전 조회 1,852
18년 전 조회 1,098
18년 전 조회 1,169
18년 전 조회 1,017
18년 전 조회 1,005
18년 전 조회 1,093
18년 전 조회 2,578
18년 전 조회 1,545
18년 전 조회 1,633
18년 전 조회 1,200
18년 전 조회 1,869
18년 전 조회 1,515
18년 전 조회 1,482
18년 전 조회 1,708
🐛 버그신고