I studied the use of custom functions for event handlers. In the example below, I am trying to trigger a warning when the user clicks a button.
But a warning window appears immediately after the page loads! What am I doing wrong? (the commented part does the same).
If I define a bclick () function like
function bclick(foo, bar){ ... }
The result is also the same.
Js in title:
<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>
Corresponding HTML in the body:
<button>Click Me!</button>
function jquery events
user105090
source share