예제 6-17. for 문을 이용하여 10px~35px까지 텍스트 출력
WEB/JAVASCRIPT-CONCEPT 2017. 11. 13. 09:17 |1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>for 문</title></head> <body> <h3>for 문으로 10px~35px 크기 출력</h3> <hr> <script> // document.write("<span style='font-size:10px'>10px</span>");를 출력하면 10px 크기로 글자가 출력된다 for(var size=10; size<=35; size+=5) { // 5씩 증가 document.write("<span "); document.write("style='font-size:" + size + "px'>"); document.write(size + "px"); // size는 출력되는 글자 document.write("</span>"); } </script> </body> </html> | cs |
'WEB > JAVASCRIPT-CONCEPT' 카테고리의 다른 글
예제 6-19. do-while 문으로 0에서 n까지의 합 구하기 (0) | 2017.11.13 |
---|---|
예제 6-18. while 문으로 0~n까지의 합 구하기 (0) | 2017.11.13 |
예제 6-16. switch 문 사용 (0) | 2017.11.13 |
예제 6-15. if-else 사용 (0) | 2017.11.13 |
예제 6-14. 문자열 연산 (0) | 2017.11.13 |