I have a link which I load a specific div with, but I would like it to load another div if I press it the third time. How can this be done?
I guess you would do something like defining a variable which is 0, and when it’s 3 do something else. I know how to this quite simple stuff in PHP but really don’t have good jQuery experience.
To be basic, what I want is something like this: click, click, click (new function)
This is my current js code:
$(".nav").click(function(e){
e.preventDefault();
$.get(this.href, function(data) {
$(this).html(data).fadeIn("fast");
});
});
If there is a single div, just declare a global variable like
var counter = 0;and then in code increment counter on click eventcounter++and check if it is 3, and if it is 3, perform the action likeif(counter == 3) { /*your action*/ }