프로그램 공부 로그/JSP
Output
HyoungJunYoon
2021. 1. 4. 21:38
- innerHTML
ex)
<div id="test"></div> // 11
<script>
document.getElementById("test").innerHTML = 5 + 6;
</script>
- document.write()
ex)
<div>test</div> // test
<script>
document.write(5+6); // 11
</script>
* <button type="button" onclick="document.write(5 + 6)">Try it</button> // 11(기존의 HTML은 모두 날라가고 document.write 결과만 남는다.)
* HTML 문서가 로드된 후 document.write()를 실행하면 기존 HTML은 모두 날라갑니다.
- window.alert()
ex)
<script>
document.alert(5+6); // 11
alert(5+6);
</script>
* 알림창
* window 키워드 생략 가능
- console.log()
ex)
<script>
console.log(5+6); // 11
</script>
* 콘솔창에 출력