리자

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

· 18년 전 · 2750
<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,831
18년 전 조회 2,145
18년 전 조회 2,328
18년 전 조회 2,879
18년 전 조회 2,968
18년 전 조회 4,137
18년 전 조회 6,121
18년 전 조회 2,061
18년 전 조회 2,198
18년 전 조회 1,905
18년 전 조회 1,662
18년 전 조회 2,639
18년 전 조회 1,690
18년 전 조회 1,565
18년 전 조회 4,739
18년 전 조회 1,794
18년 전 조회 1,847
18년 전 조회 1,855
18년 전 조회 1,979
18년 전 조회 3,633
18년 전 조회 1,658
18년 전 조회 1,532
18년 전 조회 1,362
18년 전 조회 1,867
18년 전 조회 1,913
18년 전 조회 3,656
18년 전 조회 1,981
18년 전 조회 3,122
18년 전 조회 4,745
18년 전 조회 2,877
18년 전 조회 8,056
18년 전 조회 4,064
18년 전 조회 2,751
18년 전 조회 1,527
18년 전 조회 2,632
18년 전 조회 5,047
18년 전 조회 5,226
18년 전 조회 2,102
18년 전 조회 4,362
18년 전 조회 4,100
18년 전 조회 4,156
18년 전 조회 2,278
18년 전 조회 4,199
18년 전 조회 2,180
18년 전 조회 3,290
18년 전 조회 4,926
18년 전 조회 1,961
18년 전 조회 3,418
18년 전 조회 1,649
18년 전 조회 2,751
18년 전 조회 1,679
18년 전 조회 2,720
18년 전 조회 2,561
18년 전 조회 1,564
18년 전 조회 1,508
18년 전 조회 1,749
18년 전 조회 2,250
18년 전 조회 2,024
18년 전 조회 2,390
18년 전 조회 4,921
18년 전 조회 1,830
18년 전 조회 1,264
18년 전 조회 1,387
18년 전 조회 1,346
18년 전 조회 1,088
18년 전 조회 1,078
18년 전 조회 1,416
18년 전 조회 1,375
18년 전 조회 2,358
18년 전 조회 1,238
18년 전 조회 1,615
18년 전 조회 2,093
18년 전 조회 1,282
18년 전 조회 2,833
18년 전 조회 1,285
18년 전 조회 1,659
18년 전 조회 1,505
18년 전 조회 1,461
18년 전 조회 1,241
18년 전 조회 1,081
18년 전 조회 1,669
18년 전 조회 1,107
18년 전 조회 3,627
18년 전 조회 1,720
18년 전 조회 1,795
18년 전 조회 1,118
18년 전 조회 1,858
18년 전 조회 1,106
18년 전 조회 1,177
18년 전 조회 1,028
18년 전 조회 1,014
18년 전 조회 1,102
18년 전 조회 2,584
18년 전 조회 1,553
18년 전 조회 1,639
18년 전 조회 1,209
18년 전 조회 1,876
18년 전 조회 1,526
18년 전 조회 1,489
18년 전 조회 1,715
🐛 버그신고