Why does click event handler fire immediately upon page load?
You want to pass a reference to a function as a callback, and not the result of function execution: showDiv() returns some value; if no return statement was used, undefined is returned. showDiv is a reference to the function that should be executed. This should work: $(document).ready(function() { $(‘a.test’).on(“click”, showDiv); // jQuery 1.7 and higher … Read more