إنشاء عداد الرقم وعرضة في صفحة html in javascript مع onclick in javascript

<!DOCTYPE html>
<html>
<head>
    <title>Counter</title>
</head>
<body>
    <h1 id="counter">0</h1>
    <button onclick="incrementCounter()">Increment</button>

    <script>
        let count = 0;
        const counterElement = document.getElementById("counter");

        function incrementCounter() {
            count++;
            counterElement.textContent = count;
        }
    </script>
</body>
</html>
412 chars
21 lines

related categories

gistlibby LogSnag