All TalkersCode Topics

Follow TalkersCode On Social Media

jQuery Onclick Call Function

Last Updated : Jul 1, 2023

jQuery Onclick Call Function

In this article we will show you the solution of jQuery onclick call function, here we are going to show you example with the help of onclick attribute. The onclick attribute used to generate click event when selected element clicked by user.

Then value of onclick will initializing or loading that particular method and result will display on webpage whatever defined within this method.

Step By Step Guide On jQuery Onclick Call Function :-

Here we defined html block with h1 tag for heading, button for initialize dis() function call when user clicks on it.

In script block we defined function dis() there we simply displayed text string on alert() method.

The alert() method will help you to display alert message on browsers alert box. If you want to do some other process on dis() method modify it accordingly and you will get result based on it.

<!DOCTYPE html>
        <title>Onclick Call Function</title>
        <script src=""></script>
                function dis(){
                    alert("Hi Welcome All..");
        <h1>To Load Onclick Function Click Button</h1>
        <button onclick="dis()">Display</button>
  1. <!DOCTYPE html> tag which is instruct the web browser about what version of HTML file written in and it’s not have any ending tag.
  2. The<html> tag is used to indicate the beginning of HTML document.
  3. As above shown <head> tag is contain information about webpage and external file links are declared here. <title> tag is used for set the webpage title.
  4. Here we imported open source jquery library support file which is needed for coding using jquery in program.
  5. Both <head> and <title> tags having their pair end tag, so we need to close the ending tags respectively. If you’re not closed anyone of ending tag properly that is also affect the webpage result.
  6. <body> tag is beginning of main coding part because it contain coding of entire website blocks and elements described here.
  7. In script we defined function dis() definition, there we just passed text ‘Hi Welcome All..’ on alert() method to display purpose on webapge.
  8. In body block we defined h1 heading ‘To Load Onclick Function Click Button’ that help you user to understand exact concept and instruct next move. Button ‘Display’ defined with onclick event with dis() function initialization.
  9. Both </body>,</html> tags closed respectively. </body> tag indicates the end of body, Then </html> tag indicates the end of HTML document.

Conclusion :-

In conclusion now we are able to know how to define onclick call function using jquery.

Before execution of program we needs to confirm internet connection because then only that jquery file will supports defined jquery codes in document without any error.

When we executes this program on browser we can see heading ‘To Load Onclick Function Click Button’, button ‘Display’ now user needs to click on button then you can see the message ‘Hi Welcome All..’ on alert box.

Instead of onclick you can use click event within button element result will be same.

I hope this article on jQuery onclick call function helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Anjali

Experienced Computer Programmer with a broad range of experience in technology. Strengths in application development and Object Oriented architecture design, front end programming, usability and multimedia technology. Expert in coding languages such as C, C++ Java, JavaScript, PHP and more.

Follow Anjali On Linkedin 🡪