HTML 요소를 숨기거나 보이게 할 수 있다
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML 숨기기</title>
</head>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="demo">JavaScript can hide HTML elements.</p>
<button type="button" onclick="document.querySelector('#demo').style.display='none'">Click Me!</button>
</body>
</html>
See the Pen Untitled by byeolchorong (@byeolchorong) on CodePen.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML 드러내기</title>
</head>
<body>
<h2>What Can JavaScript Do?</h2>
<p>JavaScript can hide HTML elements.</p>
<p id="demo" style="display: none;">Hello JavaScript!</p>
<button type="button" onclick="document.querySelector('#demo').style.display='block'">Click Me!</button>
</body>
</html>
See the Pen Untitled by byeolchorong (@byeolchorong) on CodePen.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML 숨기고 보이게하기</title>
</head>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="demo">JavaScript can hide HTML elements.</p>
<button type="button" onclick="document.querySelector('#demo').style.display='none'">Click Me!</button>
<button type="button" onclick="document.querySelector('#demo').style.display='block'">Click Me!!!</button>
</body>
</html>
See the Pen Untitled by byeolchorong (@byeolchorong) on CodePen.
'웹 프로그래밍 기초 > 자바스크립트 맛보기' 카테고리의 다른 글
HTML과 자바스크립트 연결 2 (0) | 2025.04.01 |
---|---|
HTML과 자바스크립트 연결 1 (0) | 2025.04.01 |
자바스크립트 역할 2 (0) | 2025.04.01 |
자바스크립트 역할 1 (0) | 2025.04.01 |
자바스크립트 작성 규칙 (0) | 2025.04.01 |