gunner17,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<script>
document.addEventListener( "DOMContentLoaded" , function() {
const on = (parent, event, selector, fn) => parent.addEventListener(event, ({target}) => {
if(target = target.closest(selector)) fn(target)
});
function makeCounter() {
let currentCount = 1;
return function() {
return currentCount++;
};
}
const counter = el => {
if(!el.Counter) el.Counter = makeCounter();
el.textContent = el.Counter();
};
on(document, "click", "button", counter);
});
</script>
</head>
<body>
<button>0</button>
<button>0</button>
<button>0</button>
</body>
</html>