리자

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

· 18년 전 · 2736
<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,818
18년 전 조회 2,130
18년 전 조회 2,311
18년 전 조회 2,861
18년 전 조회 2,955
18년 전 조회 4,120
18년 전 조회 6,109
18년 전 조회 2,045
18년 전 조회 2,177
18년 전 조회 1,887
18년 전 조회 1,648
18년 전 조회 2,622
18년 전 조회 1,681
18년 전 조회 1,552
18년 전 조회 4,728
18년 전 조회 1,780
18년 전 조회 1,831
18년 전 조회 1,839
18년 전 조회 1,965
18년 전 조회 3,620
18년 전 조회 1,645
18년 전 조회 1,518
18년 전 조회 1,348
18년 전 조회 1,852
18년 전 조회 1,899
18년 전 조회 3,643
18년 전 조회 1,971
18년 전 조회 3,105
18년 전 조회 4,729
18년 전 조회 2,860
18년 전 조회 8,043
18년 전 조회 4,050
18년 전 조회 2,733
18년 전 조회 1,514
18년 전 조회 2,614
18년 전 조회 5,032
18년 전 조회 5,212
18년 전 조회 2,086
18년 전 조회 4,346
18년 전 조회 4,090
18년 전 조회 4,142
18년 전 조회 2,265
18년 전 조회 4,185
18년 전 조회 2,166
18년 전 조회 3,276
18년 전 조회 4,911
18년 전 조회 1,947
18년 전 조회 3,402
18년 전 조회 1,637
18년 전 조회 2,737
18년 전 조회 1,661
18년 전 조회 2,706
18년 전 조회 2,548
18년 전 조회 1,548
18년 전 조회 1,493
18년 전 조회 1,734
18년 전 조회 2,235
18년 전 조회 2,007
18년 전 조회 2,377
18년 전 조회 4,909
18년 전 조회 1,816
18년 전 조회 1,253
18년 전 조회 1,371
18년 전 조회 1,331
18년 전 조회 1,073
18년 전 조회 1,065
18년 전 조회 1,402
18년 전 조회 1,356
18년 전 조회 2,347
18년 전 조회 1,224
18년 전 조회 1,603
18년 전 조회 2,082
18년 전 조회 1,268
18년 전 조회 2,818
18년 전 조회 1,266
18년 전 조회 1,645
18년 전 조회 1,494
18년 전 조회 1,446
18년 전 조회 1,230
18년 전 조회 1,071
18년 전 조회 1,657
18년 전 조회 1,097
18년 전 조회 3,612
18년 전 조회 1,707
18년 전 조회 1,783
18년 전 조회 1,109
18년 전 조회 1,848
18년 전 조회 1,093
18년 전 조회 1,164
18년 전 조회 1,010
18년 전 조회 998
18년 전 조회 1,086
18년 전 조회 2,570
18년 전 조회 1,539
18년 전 조회 1,627
18년 전 조회 1,195
18년 전 조회 1,863
18년 전 조회 1,511
18년 전 조회 1,476
18년 전 조회 1,703
🐛 버그신고