alert

<!DOCTYPE html>
<body>
    <button id="btn" onclick="alertfunc()">button</button>
    <script>
        function alertfunc(){
            alert('hello!');
        }
    </script>
</body>
</html>

 

confirm

<!DOCTYPE html>
<body>
    <button id="btn" onclick="confirm_func()">button</button>
    <script>
        function confirm_func() {
            if(confirm('are you sure?')) {
                alert('yes');
            } else {
                alert('no');
            }
        }
    </script>
</body>
</html>

 

prompt

<!DOCTYPE html>
<body>
    <button id="btn" onclick="prompt_func()">button</button>
    <script>
        function prompt_func() {
            if(prompt('please write what you want to eat') == 'apple') {
                alert('oh here you are');
            } else {
                alert('have to buy other market');
            }
        }
    </script>
</body>
</html>

 

+ Recent posts