Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> </head> <body> <!--Counter--> <input type="button" value="1" data-counter> <!--One more counter:--> <input type="button" value="2" data-counter> <script> document.addEventListener('click', function(event) { if(event.target.dataset.counter != undefined) { // if the attribute exists... event.target.value++; } }); </script> </body> </html>