Reputation: 183
i am sure its a simple thing. But i cant find the solution. My Code:
var lang='de';
$('#en').click(function (){
lang='en';
});
The variable dont change / updates on click, why?
Thanks!
Solution: works not local only on Webserver for me.
Upvotes: 1
Views: 31907
Reputation: 25776
Maybe you are missing the document.ready
?
$(function(){
var lang='de';
$('#en').click(function (){
lang='en';
});
});
Upvotes: 0
Reputation: 50493
I tried this and it seems to work fine for me. More than likely you have a scope issue.
Upvotes: 1
Reputation: 7326
Sure it does. Here is the jsFiddle test -
With your Html revision it works too -
Are you sure the lang variable is within function scope?
Upvotes: 0