다음 코드를 실행하여 JavaScript를 사용하여 JavaScript에서 문서의 내용을 바꾸는 방법을 배울 수 있습니다 -
예시
<!DOCTYPE html>
<html>
<body>
<p>Click and replace this content.</p>
<button onclick = "Display()">Replace</button>
<script>
function Display() {
document.open("text/html","replace");
document.write("<p>Demo text!</p>");
document.close();
}
</script>
</body>
</html>