리자

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

· 18년 전 · 2747
<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,828
18년 전 조회 2,142
18년 전 조회 2,326
18년 전 조회 2,879
18년 전 조회 2,965
18년 전 조회 4,135
18년 전 조회 6,118
18년 전 조회 2,059
18년 전 조회 2,195
18년 전 조회 1,900
18년 전 조회 1,659
18년 전 조회 2,636
18년 전 조회 1,689
18년 전 조회 1,563
18년 전 조회 4,737
18년 전 조회 1,792
18년 전 조회 1,844
18년 전 조회 1,852
18년 전 조회 1,978
18년 전 조회 3,630
18년 전 조회 1,658
18년 전 조회 1,529
18년 전 조회 1,360
18년 전 조회 1,864
18년 전 조회 1,912
18년 전 조회 3,654
18년 전 조회 1,981
18년 전 조회 3,120
18년 전 조회 4,742
18년 전 조회 2,876
18년 전 조회 8,055
18년 전 조회 4,064
18년 전 조회 2,749
18년 전 조회 1,527
18년 전 조회 2,630
18년 전 조회 5,046
18년 전 조회 5,224
18년 전 조회 2,099
18년 전 조회 4,361
18년 전 조회 4,098
18년 전 조회 4,152
18년 전 조회 2,277
18년 전 조회 4,195
18년 전 조회 2,178
18년 전 조회 3,288
18년 전 조회 4,925
18년 전 조회 1,960
18년 전 조회 3,416
18년 전 조회 1,647
18년 전 조회 2,748
18년 전 조회 1,676
18년 전 조회 2,716
18년 전 조회 2,559
18년 전 조회 1,564
18년 전 조회 1,507
18년 전 조회 1,747
18년 전 조회 2,248
18년 전 조회 2,021
18년 전 조회 2,389
18년 전 조회 4,920
18년 전 조회 1,827
18년 전 조회 1,264
18년 전 조회 1,385
18년 전 조회 1,343
18년 전 조회 1,086
18년 전 조회 1,076
18년 전 조회 1,413
18년 전 조회 1,373
18년 전 조회 2,356
18년 전 조회 1,237
18년 전 조회 1,613
18년 전 조회 2,092
18년 전 조회 1,280
18년 전 조회 2,831
18년 전 조회 1,283
18년 전 조회 1,658
18년 전 조회 1,503
18년 전 조회 1,460
18년 전 조회 1,238
18년 전 조회 1,079
18년 전 조회 1,667
18년 전 조회 1,106
18년 전 조회 3,625
18년 전 조회 1,717
18년 전 조회 1,794
18년 전 조회 1,115
18년 전 조회 1,856
18년 전 조회 1,104
18년 전 조회 1,175
18년 전 조회 1,025
18년 전 조회 1,014
18년 전 조회 1,100
18년 전 조회 2,582
18년 전 조회 1,549
18년 전 조회 1,636
18년 전 조회 1,206
18년 전 조회 1,875
18년 전 조회 1,524
18년 전 조회 1,487
18년 전 조회 1,713
🐛 버그신고