HTMLify

Create Button in Js
Views: 303 | Author: djdj
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title></title>
        <link rel="stylesheet" href="">
    </head>
    <body>
        <button style="background-color:skyblue;">
            Click me
        </button>
        <script>
            let btn = document.querySelector('button');
            btn.addEventListener('click',showMsg);
            function showMsg(){
                alert("Hello");
            }
        </script>
    </body>
</html>

Comments