Here is my HTML/JavaScript:
Variables and methods declared inside the $(function() function are only accessible within that. If you need to use those outside, you you make it in the global namespace like
window.functionName = functionName;