별초롱언니 2025. 4. 1. 12:34

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.