How to Use JQuery Events

In this article I have described that how to use events in JQuery.
  • 1760

Events In JQuery

  • Event handlers are methods which handles the events which happens in HTML page .
  • The  'event handler attachment' or 'event helpers' are some methods which is used for event handling.

 For example 'hide' is used to hide the information which may be in paragraph, div, span etc, when an event is occurred.

Syntax

The simple syntax to use hide() method as

<script type="text/javascript">

    $(document).ready(function () {

        $("button").click(function () {

            $("p").hide();

        });

    });

</script>

 

NOTE - In the above syntax $("p").hide() method is used to hide the information from webpage.

 

Lets take an example

 

<!DOCTYPE html>

<html>

<head>

    <script src="jquery-1.7.2.min.js" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("button").click(function () {

            $("p").hide();

        });

    });

</script>

</head>

<body>

<h2>Welcome jQuery</h2>

<p>Event handling in jquery</p>

<p>Methods to handle the events</p>

<button>Click</button>

<label>Please Click and see the result</label>

</body>

</html>

 

When we run the above program

jq event.jpg

 

when we click on "CLICK" button

 

jq evnt2.jpg

 

You may also want to read these related articles here

Ask Your Question 


Got a programming related question? You may want to post your question here
© 2019 DotNetHeaven. All rights reserved.