confirm

유석현(SeokHyun Yu)·2022년 11월 16일
0

JavaScript

목록 보기
8/44
post-thumbnail
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <input type="button" value="confirm" onclick="func()" />
      	<!-- confirm()은 사용자가 확인을 누르면 true, 취소를 누르면 false를 반환한다 -->
        <script>
            const func = () => {
                if (confirm("ok?")) {
                    alert("ok");
                } else {
                    alert("cancel");
                }
            };
        </script>
    </body>
</html>

  • 버튼 클릭

  • 확인 클릭

  • 취소 클릭

profile
Backend Engineer

0개의 댓글