javascript - How can I change global variable when it's showed in an HTML page? -
the global variable called "gv" own original value. , when call function clicking buttons in html page, gv changed. then, want show gv in html page calling alert() or else. gv has no change. how can this?
the "best" way create global add "window." in front of variable.
window.gv = 0; function testone() { window.gv = 'hi !'; } testone(); settimeout(function () { alert(window.gv); }, 500);
Comments
Post a Comment