index.html 1.19 KB
Newer Older
Joel Florentin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
<html>
    <head><title></title></head>
    <body>
        <ul id="menu">
            <li>Services</li>
        </ul>
        <button id="btn">Click</button>
        <p id="message"></p>
        <script>
            let ul = document.getElementById("menu")
            let li = document.createElement("li");
            li.textContent = "Home";
            ul.appendChild(li);
            let btn = document.querySelector("#btn");
            btn.addEventListener("mousedown",evt => {
                let message = document.querySelector("#message")
                switch (evt.button) {
                    case 0:
                    message.textContent = `${evt.button}`
                        
                        break;
                    case 1:
                        message.textContent = "Middle"
                        
                        break;
                    case 2:
                        message.textContent = "Right"
                        break;
                
                    default:
                    message.textContent = "Left"
                        
                        break;
                }
                
            })
        </script>
    </body>
</html>