I've been exploring the use of custom functions for event handlers. In this stripped down example, I'm trying to get an alert to pop up when the user clicks a button.
But the alert box pops up immediately as the page loads! What am I doing wrong? ( the commented portion does the exact same thing).
If I define the bclick() function like
function bclick(foo, bar){ ... }
The result is also the same.
JS in the header:
<script type="text/javascript">
var bclick = function(foo, bar){alert( foo + " " + bar + "\n");}
//$(document).ready(function(){
// $("button").click(bclick("Button","Clicked"));
// });
$("button").click(bclick("Button","Clicked"));
</script>
Relevant HTML in the body:
<button>Click Me!</button>