Skip to main content Accessibility Feedback

Counter

This is powered by a DOM manipulation library you’ll create that can be easily customized by developers like this.

// Listen for custom counter:increase-before events
// Stop counting once you reach 20
document.addEventListener('counter:increase-before', function (event) {
	if (event.detail.count > 19) {
		event.preventDefault();
		alert(`You've reached the max allowed.`);
	}
});

// Create a new counter
let count = new Counter('#app', {
	buttonText: 'Increase By 1',
	start: 10
});