Counting clicks on anchor tag

耗尽温柔 提交于 2019-12-12 04:06:31

问题


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.



来源:https://stackoverflow.com/questions/4972290/counting-clicks-on-anchor-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!