I have a <a href="" > </a>
on a page on my webiste. I wanted to count the number of clicks on this link by the user and display it. How can this be done?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
best way to represent a counter for each a tag on your document and store the data with jquery.data, increasing the counter on each click,
example shown in here : http://jsfiddle.net/ShlomiKomemi/dvdPd/13/
回答2:
href can have a javascript function call that can do the count and redirect the user to the original page.
Or you can point the href to a server side page that can do the count and redirect the user to the original page.