I need a global varible, starting at 0.
Then I have a few functions. Let's say if the function a) runs, the variable will get +2, if function b) runs, the variable will get +5. There will be several functions in a row, so it might be that the variable will get +2 from the first function and +5 from the second, so it will be 7 in the end, or 15 if b) runs 3 times, or whatever. The variable can only go higher, besides the whole page gets reloaded, then it goes back to 0.
The last of the functions, c), needs if statements, like if variable==7 in the end, do this and if variable==15 do this.
I already have this javascript code:
var answer = 0;
jQuery(".a").click(function(){
jQuery("withthis").dothis();
// and permanently add +2 to my variable "answer"
});
jQuery(".b").click(function(){
jQuery("withthis").dothis();
// and permanently add +5 to my variable "answer"
});
jQuery(".c").click(function(){
jQuery("withthis").dothis();
if (answer==7) {
jQuery("withthis").dothis();
}
if (answer==15) {
jQuery("withthis").dothis();
}
});
Aucun commentaire:
Enregistrer un commentaire