But, browser console shows the updateErrorMessage function is not defined. :). Why not just define the method by itself: UPDATE: With a small change to how your method is defined I can get it to work: Stay away from putting the events inline with the elements! To learn more, see our tips on writing great answers. Multi-Function jQuery onClick to Call Script Having done a lot of research and testing, I've pieced together several snippets to achieve almost 100%, thanks to multiple Stack articles (such as How to Click to show & Click to call?). Onclick ajax function in php. What is the best way to play a chord larger than your hand? This is an example function, to demonstrate the problem. Questions: I have a huge jQuery application, and I’m using the below two methods for click events. Javascript Web Development Front End Technology The onClick event is the most frequently used event type, which occurs when a user clicks the left button of the mouse. Jquery onclick call function. Since you're just learning JQuery, stick to the convention. // Get the button, and when the user clicks on it, execute myFunction document.getElementById("myBtn").onclick = function() {myFunction()}; /* myFunction toggles between adding and removing the show class, which is used to hide and show the dropdown content */ document.getElementById("myBtn").onclick = function() {myFunction ()}; /* myFunction toggles between adding and removing the show class, which is used to hide and show the dropdown content */. Government censors HTTPS traffic to our website. site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. Can the US House/Congress impeach/convict a private citizen that hasn't held office? Will a refusal to enter the US mean I can't enter Canada either? How to use the jQuery onClick event What is this logical fallacy? How to determine a limit of integration from a known integral? Let’s say the following is our button − We need to call a function … If your IDs are clearly named, it will be easy for a reader to understand. I have come across one issue I would love to find the correct resolve for. Or you can give the element an ID and bind the click handler in jQuery.