//the click method takes a callback that gets called when the button is clicked $("#exeBtn").click(function(){ var poorVariable = "Alas woe as me for I only live in the scope of this click callback"; alert(poorVariable); }); /* When you look at your debugger you will see something like Uncaught ReferenceError: poorVariable is not defined when we make our console.info(poorVariable) call because the poorVariable is no longer with us at this point :( poor poor poorVariable */ console.info(poorVariable);
<div id="contentDumper"></div> <input type="button" id="exeBtn" value="click me" />