I'm trying to run a function on .change()
and .click()
events with different arguments passed to that function. Function foo
runs two times automatically on page load (once for each event). On top of that .change()
and .click()
events don't do anything when I'm trying to invoke them.
$(document).ready(function(){
function foo(bar){
alert("This function runs 2 times on page load");
}
$("#some-select").change(foo(false));
$("#some-button").click(foo(true));
});
I expect foo
function not to run automatically on page load.