count clicks for each specific link

371 Views Asked by At

I have a page of distinct links. I'm trying to create a JavaScript counter that counts how many times each individual link has been clicked.

I can count general clicks on any <a href> element. How can I count clicks on each individual link?

So,

  1. Bookmark #1 - Cracked.com - Clicked 3 times
  2. Bookmark #2 - Collegehumor.com - Clicked 1 times
  3. etc...

var clickcounts = '0';

function count() {
  clickcounts++;
  alert(clickcounts);
}
<a href="javascript:count();">count clicks</a>

0

There are 0 best solutions below