리자

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

· 18년 전 · 2958
<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년 전 조회 3,065
18년 전 조회 2,380
18년 전 조회 2,564
18년 전 조회 3,108
18년 전 조회 3,198
18년 전 조회 4,369
18년 전 조회 6,353
18년 전 조회 2,307
18년 전 조회 2,420
18년 전 조회 2,115
18년 전 조회 1,867
18년 전 조회 2,860
18년 전 조회 1,897
18년 전 조회 1,782
18년 전 조회 4,969
18년 전 조회 2,023
18년 전 조회 2,069
18년 전 조회 2,069
18년 전 조회 2,203
18년 전 조회 3,858
18년 전 조회 1,881
18년 전 조회 1,759
18년 전 조회 1,577
18년 전 조회 2,074
18년 전 조회 2,122
18년 전 조회 3,890
18년 전 조회 2,218
18년 전 조회 3,372
18년 전 조회 4,984
18년 전 조회 3,112
18년 전 조회 8,276
18년 전 조회 4,295
18년 전 조회 2,993
18년 전 조회 1,775
18년 전 조회 2,870
18년 전 조회 5,277
18년 전 조회 5,449
18년 전 조회 2,318
18년 전 조회 4,580
18년 전 조회 4,338
18년 전 조회 4,376
18년 전 조회 2,513
18년 전 조회 4,428
18년 전 조회 2,413
18년 전 조회 3,527
18년 전 조회 5,162
18년 전 조회 2,178
18년 전 조회 3,646
18년 전 조회 1,862
18년 전 조회 2,959
18년 전 조회 1,915
18년 전 조회 2,953
18년 전 조회 2,783
18년 전 조회 1,796
18년 전 조회 1,748
18년 전 조회 1,983
18년 전 조회 2,483
18년 전 조회 2,263
18년 전 조회 2,620
18년 전 조회 5,143
18년 전 조회 2,042
18년 전 조회 1,472
18년 전 조회 1,602
18년 전 조회 1,572
18년 전 조회 1,290
18년 전 조회 1,301
18년 전 조회 1,634
18년 전 조회 1,580
18년 전 조회 2,584
18년 전 조회 1,453
18년 전 조회 1,837
18년 전 조회 2,318
18년 전 조회 1,500
18년 전 조회 3,071
18년 전 조회 1,503
18년 전 조회 1,873
18년 전 조회 1,733
18년 전 조회 1,665
18년 전 조회 1,459
18년 전 조회 1,293
18년 전 조회 1,900
18년 전 조회 1,335
18년 전 조회 3,843
18년 전 조회 1,950
18년 전 조회 2,031
18년 전 조회 1,353
18년 전 조회 2,092
18년 전 조회 1,328
18년 전 조회 1,396
18년 전 조회 1,240
18년 전 조회 1,231
18년 전 조회 1,315
18년 전 조회 2,816
18년 전 조회 1,772
18년 전 조회 1,871
18년 전 조회 1,416
18년 전 조회 2,083
18년 전 조회 1,730
18년 전 조회 1,709
18년 전 조회 1,921