scope - write parent function var in javascript -


how change value of variable in parent function in javascript

for example:

function parent() {      var changeme = 0;       function child() {           changeme = 1;      } } 

thanks help!

the variable changeme within child() referring changeme in parent(). call child() , change it.

jsfiddle

function parent() {     var changeme = 0;      function child() {         changeme = 1;     }     child();      alert(changeme); } parent(); 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

php - Boolean search on database with 5 million rows, very slow -

css - Text drops down with smaller window -