Introduction:

  • In this article we will explain how call click event of html HTML element using jquery or What is click() method in jquery or why use click() method in jquery with example.

 

Description:

The jQuery click() method is used to attaches an event handler function to an HTML element. this function is executed when the user clicks on the HTML element.

Let’s see simple Example:

jQuery  click () Method

 

In this example when we clicks on anchor tag elements show an alert message.

 

 !DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Example of jQuery </title>
    <script src="Scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("a").click(function () {
                alert("you clicked it.");
            });
        });
    </script>
</head>
<body>
    <div style="text-align:center;">
       <a href="#">click here</a>
     </div>    
</body>
</html>

 

OutPut:


how use click event in jquery


In above example when you click on “click here” link then execute click event and show alert message. 


 

I hope this article will help to you.

 

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like