반응형
<!DOCTYPE html>
<html>
<body>
<h1>My First Web Page</h1>
<p>My First Paragraph</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 1 + 2;
document.write(2 + 3);
console.log(3 + 4);
</script>
<button type="button" onclick="alert(5 + 6)">Try it</button>
</body>
</html>
방법1 : html "demo" element의 innerHTML로 집어넣기
document.getElementById("demo").innerHTML = 1 + 2;
방법2 : html body에 쓰기
document.write(2 + 3);
방법3 : 브라우저 콘솔창에 쓰기
console.log(3 + 4);
방법4 : 브라우저 메시지박스로 띄우기
alert(5 + 6);
반응형
댓글