Reputation: 35
This onClick function does not run the console.log in the code snippet below, any ideas?
var clickFunction = function myfunc() {
return function (){
return console.log('here');
}
};
<button onClick="clickFunction()"> Click here</button>
Thanks for your time
Upvotes: 2
Views: 52
Reputation: 23786
Because you're calling a function that returns a function. If you want to run the function that is returned you would need to do: clickFunction()()
Upvotes: 2