How to change an variable inside a function? I trying to archive an simply toggle function based on one preassigned value. Here the code and here http://jsfiddle.net/StartStep/jLQyx/
<p onclick="testit()">CLick</p>
<p id="value">Value</p>
var valuediv = document.getElementById("value");
function testit() {
if (c == 1) {
var c = 1;
valuediv.innerHTML = c
} else {
var c = 0;
valuediv.innerHTML = c
}
}
c == 1why are you then assigningc = 1?