In the example below, myFonk is called instantly; it doesn\'t wait for the click event. Why not?
function myFonk(info) {
$(\"#result
It's because you're not passing a reference to the functions. You're calling the functions and using the results as the event handlers for click.
This will fix that for you...
function myFonk(info) {
$("#result").html(info);
}
function getText(text){
return function() {
myFonk(text);
}
}
$(document).ready(function() {
$("#b1").click(function() {
getText("getText")
});
$("#b2").click(function() {
myFonk("myFonk")
});
});