실습문제 6-3
WEB/TRAINNING 2017. 11. 13. 16:41 |3. document.write()를 이용하여 문제 2에 주어진 <script> 태그에 자바스크립트 코드를 완성하여 다음과 같이 출력되게 하라.
(1)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <!DOCTYPE html> <html> <head> <title>document.write()</title> </head> <body> <script> for ( var x = 0 ; x < 5 ; x ++ ) { for( var y = 0 ; y <= x ; y ++) { document.write("*"); } document.write("<br>"); } </script> </body> </html> | cs |
(2)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <!DOCTYPE html> <html> <head> <title>document.write()</title> </head> <body> <script> document.write("<h3>document.write()로 만들기</h3>"); document.write("<hr>"); document.write("<table border='1'>"); document.write("<tbody>"); document.write("<tr>"); document.write("<th>"); document.write("n"); for (var i = 0 ; i <= 9 ; i ++ ) { document.write("<td>"); document.write(i); document.write("</td>"); } document.write("</th>"); document.write("</tr>"); document.write("<tr>"); document.write("<th>"); document.write("n<sup>2</sup>"); for (var i = 0 ; i <= 9 ; i ++ ) { document.write("<td>"); document.write(i*i); document.write("</td>"); } document.write("</th>"); document.write("</tr>"); document.write("<tbody>"); document.write("</table>"); </script> </body> </html> | cs |