리자

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

· 18년 전 · 2745
<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,826
18년 전 조회 2,142
18년 전 조회 2,323
18년 전 조회 2,874
18년 전 조회 2,965
18년 전 조회 4,133
18년 전 조회 6,117
18년 전 조회 2,057
18년 전 조회 2,194
18년 전 조회 1,900
18년 전 조회 1,659
18년 전 조회 2,634
18년 전 조회 1,689
18년 전 조회 1,562
18년 전 조회 4,737
18년 전 조회 1,790
18년 전 조회 1,842
18년 전 조회 1,849
18년 전 조회 1,978
18년 전 조회 3,630
18년 전 조회 1,655
18년 전 조회 1,527
18년 전 조회 1,359
18년 전 조회 1,863
18년 전 조회 1,911
18년 전 조회 3,652
18년 전 조회 1,981
18년 전 조회 3,116
18년 전 조회 4,742
18년 전 조회 2,875
18년 전 조회 8,053
18년 전 조회 4,063
18년 전 조회 2,747
18년 전 조회 1,525
18년 전 조회 2,629
18년 전 조회 5,045
18년 전 조회 5,223
18년 전 조회 2,097
18년 전 조회 4,360
18년 전 조회 4,097
18년 전 조회 4,151
18년 전 조회 2,277
18년 전 조회 4,194
18년 전 조회 2,177
18년 전 조회 3,288
18년 전 조회 4,923
18년 전 조회 1,957
18년 전 조회 3,414
18년 전 조회 1,647
18년 전 조회 2,746
18년 전 조회 1,674
18년 전 조회 2,716
18년 전 조회 2,558
18년 전 조회 1,561
18년 전 조회 1,503
18년 전 조회 1,745
18년 전 조회 2,247
18년 전 조회 2,018
18년 전 조회 2,389
18년 전 조회 4,919
18년 전 조회 1,823
18년 전 조회 1,262
18년 전 조회 1,384
18년 전 조회 1,342
18년 전 조회 1,085
18년 전 조회 1,074
18년 전 조회 1,410
18년 전 조회 1,372
18년 전 조회 2,354
18년 전 조회 1,236
18년 전 조회 1,613
18년 전 조회 2,092
18년 전 조회 1,278
18년 전 조회 2,830
18년 전 조회 1,283
18년 전 조회 1,654
18년 전 조회 1,502
18년 전 조회 1,460
18년 전 조회 1,237
18년 전 조회 1,079
18년 전 조회 1,667
18년 전 조회 1,105
18년 전 조회 3,623
18년 전 조회 1,716
18년 전 조회 1,792
18년 전 조회 1,115
18년 전 조회 1,856
18년 전 조회 1,101
18년 전 조회 1,173
18년 전 조회 1,021
18년 전 조회 1,011
18년 전 조회 1,099
18년 전 조회 2,582
18년 전 조회 1,549
18년 전 조회 1,634
18년 전 조회 1,205
18년 전 조회 1,874
18년 전 조회 1,521
18년 전 조회 1,484
18년 전 조회 1,712
🐛 버그신고