JSFiddle - React, Tailwind, and code Playground
HTML
<button type="button" id="a">A</button>
<button type="button" id="b">B</button>
<button type="button" id="c">C</button>
<button type="button" id="d">D</button>
<button type="button" id="e">E</button>
<textarea rows="5" cols="40" id="results">
</textarea>
JavaScript
var buttonClicked = {"a":0,"b":0,"c":0,"d":0,"e":0};
$("button").click(function() {
$("#results").text('');
var clickedId = $(this).attr('id');
buttonClicked[clickedId] +=1
// Here you update the cookie for the count of clicks for that A URL
displayCounter();
});
function displayCounter()
{
for(var elem in buttonClicked)
{
if (buttonClicked[elem] != 0)
{
$("#results").append(elem + " clicked " + buttonClicked[elem] + "\n");
}
}
}