document.write() , writeln()
페이지 정보
본문
<script>
document.write("<font color=red>안녕하세요</font><br>");
document.writeln("<font color=blue>안녕하세요</font>");
document.write("<font color=red>안녕하세요</font>");
</script>
==== tip ====
write(), writeln() 함수는 사용법이 같다.
writeln() 함수는 write() + \n(엔터) 역활로 출력하게 된다.
하지만 HTML 특성 상 한 칸 띄어쓴 것처럼 보인다.
브라우저에서 제대로 된 줄바꿈으로 처리를 하려면 아래의 예제와 같이 <pre>태그로 감싸면 된다.
<pre>
<script>
document.write("<font color=red>안녕하세요</font><br>");
document.writeln("<font color=blue>안녕하세요</font>");
document.write("<font color=red>안녕하세요</font>");
</script>
</pre>
- 이전글confirm() 예제 21.07.16
- 다음글● 자바 스크립트란 ? 21.07.16
댓글목록
등록된 댓글이 없습니다.