You can provide an anonymous handler function at the point of the .on() call, as the examples have done above, or declare a named function and pass its name: This is an example function, to demonstrate the problem. How to call a JavaScript function from an onClick event? 888-555-1212 Ext 222) if commas and extension are present, standard tel if not (ex. Uncaught ReferenceError: updateErrorMessage is not defined Solution. Making an animation of an evolving digital elevation model. Do you wish to execute some custom code on click of a button, a hyperlink, etc.? Given multiple containers as shown: Why did Churchill become the PM of Britain during WWII instead of Lord Halifax? How do I check whether a checkbox is checked in jQuery? Attach a function to the click event: $ ( selector ).click ( function ) Try it. Description. Let’s say the following is our button − We need to call a function … How would I bias my binary classifier to prefer false positive errors over false negatives? Calling Jquery function from link onClick attribute. If you want, you can just stick your script in a