본문 바로가기

Javascript

(Javascript) 자바스크립트의 반복문으로 테이블 만들기

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
자바스크립트로 for문 돌려서 테이블을 만들 수 있다길래 만들어 보았습니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
    <table width="150px" height="80px" border="1px solid red">
        <tbody>
            <script>
            for (var f=1; f <10; f++){
            document.write('<tr>');
            document.write('<td  width="150px" height="50px" style="border:1px solid red; text-align:center;">');
            document.write ((f));
            document.write ('</td>');
            document.write ('</tr>');}
            </script>
        </tbody>
    </table>
</body>
</html>
cs


결과


출처 : http://eproo.tistory.com/107