 <p>An inline event handler like your <code>onclick='...'</code> can only reference globally scoped variables and functions, but if your variable named <code>global</code> is declared inside a function (inside a document.ready handler, for example) then it is not global and the inline attribute event handler can't see it.</p>