0

I asked this question but did not explain it thoroughly. I have a regular link:

<a href="http://www.google.com">Click Me</a>

I want the change the href after the link is clicked 10 times not by the individual use but clicked 10 total times by all users.My jquery is obviously flawed but here is what i have:

var count = 0;
$(document).ready(function(){
$('a').click(function(){
count++;
if(count > 10){
$('a').attr("href","https://www.yahoo.com");
}
});
});

I am new to jQuery but from what ive read cookies and local storage store individual users information not the total websites information i could be wrong but i appriciate the help

Rodrigo Lessa
  • 69
  • 3
  • 11
  • If you simply didn't explain your question well enough then you should edit your other question, not create a new one. And from what I see on your other one you could very easily edit it to make it clearer. – Andrew Lively Aug 28 '13 at 04:11

2 Answers2

0

If you need to store the data across all the users, then you need to use a server side storage for the counter.

When ever the link is clicked set an ajax request to the server indicating it where it increments the counter... then when the page is rendered you need to check the condition and accordingly set the src attribute

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
0

Jquery is a client side scripting language. So you cant track all users clicks only with jquery. So you have to use some server side language with a database. So when a user clicked on the link you can send it and add a flag in a database table with an ajax request.

N8FURY
  • 9,490
  • 3
  • 14
  • 14