리자

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

· 18년 전 · 2737
<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,819
18년 전 조회 2,132
18년 전 조회 2,311
18년 전 조회 2,864
18년 전 조회 2,956
18년 전 조회 4,122
18년 전 조회 6,111
18년 전 조회 2,047
18년 전 조회 2,178
18년 전 조회 1,890
18년 전 조회 1,649
18년 전 조회 2,625
18년 전 조회 1,682
18년 전 조회 1,552
18년 전 조회 4,730
18년 전 조회 1,781
18년 전 조회 1,832
18년 전 조회 1,840
18년 전 조회 1,965
18년 전 조회 3,621
18년 전 조회 1,647
18년 전 조회 1,520
18년 전 조회 1,349
18년 전 조회 1,853
18년 전 조회 1,900
18년 전 조회 3,645
18년 전 조회 1,973
18년 전 조회 3,106
18년 전 조회 4,730
18년 전 조회 2,861
18년 전 조회 8,044
18년 전 조회 4,051
18년 전 조회 2,736
18년 전 조회 1,516
18년 전 조회 2,617
18년 전 조회 5,033
18년 전 조회 5,215
18년 전 조회 2,087
18년 전 조회 4,350
18년 전 조회 4,092
18년 전 조회 4,143
18년 전 조회 2,267
18년 전 조회 4,187
18년 전 조회 2,169
18년 전 조회 3,279
18년 전 조회 4,912
18년 전 조회 1,949
18년 전 조회 3,405
18년 전 조회 1,638
18년 전 조회 2,738
18년 전 조회 1,661
18년 전 조회 2,709
18년 전 조회 2,548
18년 전 조회 1,550
18년 전 조회 1,494
18년 전 조회 1,736
18년 전 조회 2,238
18년 전 조회 2,008
18년 전 조회 2,378
18년 전 조회 4,909
18년 전 조회 1,818
18년 전 조회 1,254
18년 전 조회 1,373
18년 전 조회 1,334
18년 전 조회 1,075
18년 전 조회 1,067
18년 전 조회 1,402
18년 전 조회 1,359
18년 전 조회 2,349
18년 전 조회 1,226
18년 전 조회 1,603
18년 전 조회 2,082
18년 전 조회 1,268
18년 전 조회 2,820
18년 전 조회 1,268
18년 전 조회 1,646
18년 전 조회 1,495
18년 전 조회 1,448
18년 전 조회 1,230
18년 전 조회 1,072
18년 전 조회 1,657
18년 전 조회 1,097
18년 전 조회 3,613
18년 전 조회 1,707
18년 전 조회 1,784
18년 전 조회 1,109
18년 전 조회 1,848
18년 전 조회 1,094
18년 전 조회 1,165
18년 전 조회 1,012
18년 전 조회 999
18년 전 조회 1,087
18년 전 조회 2,570
18년 전 조회 1,539
18년 전 조회 1,629
18년 전 조회 1,197
18년 전 조회 1,864
18년 전 조회 1,511
18년 전 조회 1,477
18년 전 조회 1,704
🐛 버그신고