Global und Lokal
by pw_we1
HTML
<button id="btnLocal">Lokal: ???</button>
<button id="btnGlobal">Global: ???</button>
JavaScript
var x = 0;
function local(a){
var x = 0;
a++;
$("#btnLocal").html("Lokal: "+(x+a));
}
function global(){
x++
$("#btnGlobal").html("Global: "+x);
}
$("#btnLocal").click(function() { local(x); });
$("#btnGlobal").click(function() { global(); });