리자

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

· 18년 전 · 2738
<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,820
18년 전 조회 2,133
18년 전 조회 2,313
18년 전 조회 2,866
18년 전 조회 2,957
18년 전 조회 4,124
18년 전 조회 6,113
18년 전 조회 2,048
18년 전 조회 2,179
18년 전 조회 1,890
18년 전 조회 1,651
18년 전 조회 2,626
18년 전 조회 1,684
18년 전 조회 1,554
18년 전 조회 4,731
18년 전 조회 1,783
18년 전 조회 1,834
18년 전 조회 1,842
18년 전 조회 1,968
18년 전 조회 3,622
18년 전 조회 1,648
18년 전 조회 1,521
18년 전 조회 1,351
18년 전 조회 1,856
18년 전 조회 1,903
18년 전 조회 3,647
18년 전 조회 1,974
18년 전 조회 3,109
18년 전 조회 4,732
18년 전 조회 2,864
18년 전 조회 8,044
18년 전 조회 4,053
18년 전 조회 2,738
18년 전 조회 1,519
18년 전 조회 2,618
18년 전 조회 5,035
18년 전 조회 5,215
18년 전 조회 2,091
18년 전 조회 4,350
18년 전 조회 4,093
18년 전 조회 4,147
18년 전 조회 2,269
18년 전 조회 4,189
18년 전 조회 2,170
18년 전 조회 3,280
18년 전 조회 4,914
18년 전 조회 1,950
18년 전 조회 3,408
18년 전 조회 1,640
18년 전 조회 2,739
18년 전 조회 1,665
18년 전 조회 2,710
18년 전 조회 2,550
18년 전 조회 1,553
18년 전 조회 1,496
18년 전 조회 1,737
18년 전 조회 2,239
18년 전 조회 2,010
18년 전 조회 2,380
18년 전 조회 4,911
18년 전 조회 1,819
18년 전 조회 1,257
18년 전 조회 1,376
18년 전 조회 1,337
18년 전 조회 1,078
18년 전 조회 1,068
18년 전 조회 1,404
18년 전 조회 1,362
18년 전 조회 2,352
18년 전 조회 1,228
18년 전 조회 1,606
18년 전 조회 2,085
18년 전 조회 1,270
18년 전 조회 2,822
18년 전 조회 1,271
18년 전 조회 1,648
18년 전 조회 1,497
18년 전 조회 1,451
18년 전 조회 1,231
18년 전 조회 1,074
18년 전 조회 1,658
18년 전 조회 1,098
18년 전 조회 3,617
18년 전 조회 1,711
18년 전 조회 1,786
18년 전 조회 1,111
18년 전 조회 1,850
18년 전 조회 1,096
18년 전 조회 1,166
18년 전 조회 1,014
18년 전 조회 999
18년 전 조회 1,088
18년 전 조회 2,574
18년 전 조회 1,541
18년 전 조회 1,631
18년 전 조회 1,199
18년 전 조회 1,866
18년 전 조회 1,513
18년 전 조회 1,480
18년 전 조회 1,705
🐛 버그신고