I am new to jQuery and am having difficulty getting a .change event to call a named function. When I use an anonymous function, it works fine.
This works fine:
$(function() {
$("select").change(function() {
alert("hello");
});
});
This does not work (i.e. has not effect):
$(function() {
$("select").change(processSelection());
function processSelection() {alert('Hello!');};
});
Any assistance much appreciated!
You are passing the function as an argument, not calling it, so you don’t need the
()afterprocessSelection. So, you should doinstead of