Jquery Event

Advertisements

Prev Tutorial Next Tutorial

Event

Event are occurred when something happens on web page. Some example of events are;

  • moving a mouse over an element
  • Click mouse over an element
  • selecting a radio button
  • clicking on an element

Syntax

$("p").click();

Next you must be defined what should happen when the event fires. You must pass a function to the event:

Syntax

$("p").click(function(){
  // action perform
});

Example of Event in jQuery

<!DOCTYPE html>
<html>
<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $(".para").click(function(){
        $(this).hide();
    });
});
</script>
</head>
<body>

<p>Click on below text, I will disappear.</p>

<p class="para">Click me please!</p>
<p class="para">Click me too!</p>

</body>
</html>

Output

Click on below text, I will disappear.

Click me please!

Click me too!

Common DOM Events

Mouse EventsKeyboard EventsForm EventsDocument/Window Events
clickkeypresssubmitload
dblclickkeydownchangeresize
mouseenterkeyupfocusscroll
mouseleaveblurunload

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements