Colorful Number Counter
About this app
A fun and interactive number counter app that allows users to increment and decrement numbers while keeping track of the total.
Colorful Number Counter Colorful Number Counter 0 Increment Decrement
Related apps
Put this on your site
Source
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Colorful Number Counter</title>
<meta name="description" content="A fun and interactive number counter app that allows users to increment and decrement numbers while keeping track of the total.">
<meta name="keywords" content="number counter, fun, interactive, increment, decrement, colorful app">
<!-- Libraries -->
<!-- jQuery (3.6.0) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js" crossorigin="anonymous"></script>
<!-- Bootstrap CSS (5.3.3) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" crossorigin="anonymous">
<!-- Bootstrap JS (5.3.3) -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" crossorigin="anonymous">
</script>
<!-- Font Awesome (6.6.0) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.6.0/css/fontawesome.min.css" crossorigin="anonymous">
<script type="text/javascript">
try {
// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
let count = 0;
const totalDisplay = document.getElementById('total');
document.getElementById('incrementButton').addEventListener('click', function() {
count++;
updateDisplay();
});
document.getElementById('decrementButton').addEventListener('click', function() {
count--;
updateDisplay();
});
function updateDisplay() {
totalDisplay.innerText = count;
totalDisplay.style.color = count > 0 ? 'green' : (count < 0 ? 'red' : 'black');
animateValue(totalDisplay, count);
}
function animateValue(target, value) {
const start = Number(target.innerText);
const end = value;
const duration = 500;
const frameDuration = 1000 / 60;
const totalFrames = Math.round(duration / frameDuration);
let currentFrame = 0;
const updateFrame = () => {
currentFrame++;
const progress = Math.min(currentFrame / totalFrames, 1);
target.innerText = Math.round(progress * (end - start) + start);
if (currentFrame < totalFrames) {
requestAnimationFrame(updateFrame);
}
};
requestAnimationFrame(updateFrame);
}
});
} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>
<style>
body {
background: linear-gradient(90deg, #f0f4c3, #add8e6);
color: #333;
font-family: Arial, sans-serif;
}
#main-container {
text-align: center;
margin-top: 50px;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
background: rgba(255, 255, 255, 0.8);
}
h1 {
color: #3f51b5;
font-size: 2.5rem;
}
.btn {
margin: 10px;
padding: 15px 30px;
font-size: 1.5rem;
}
.total {
font-size: 3rem;
font-weight: bold;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>Colorful Number Counter</h1>
<div class="total" id="total">0</div>
<button id="incrementButton" class="btn btn-success">Increment</button>
<button id="decrementButton" class="btn btn-danger">Decrement</button>
</div>
</body>
</html>
NEW APPS
These are apps made by the community!