I try to implement the following code:
<a href = "http://www.google.com"/ id="external">go to google</a>
<span id="num1"></span>// to show the number of clicks so far.
<a href = "index.php" id="internal">go to home</a>
<span id="num2"></span>>// to show the number of clicks so far.
<script>
$(document).ready(function() {
var count1=0;
var count2=0;
$("#external").click(function(){
count1++;
});
$("#num1").html(count1);
$("#internal").click(function(){
count2++
});
$("#num2").html(count2);
});
</script>
I am not sure what I did above is right for the purpose of keeping track of the number of clicks on each link, and the problem is that when the page is loaded again, the count variable will be reset to 0, I wonder if I need to insert the count variable into database or is there even more efficient way to do this, any one could help me with that, any help will be greatly appreciated!