Events

jQuery events are the actions that can be detected by your web application. They are used to create dynamic web pages. An event shows the exact moment when something happens.

These are some examples of events.

  • A mouse click
  • An HTML form submission
  • A web page loading
  • A keystroke on the keyboard
  • Scrolling of the web page etc.

These events can be categorized on the basis their types:

Mouse Events

  • click
  • dblclick
  • mouseenter
  • mouseleave

Keyboard Events

  • keyup
  • keydown
  • keypress

Form Events

  • submit
  • change
  • blur
  • focus

Document/Window Events

  • load
  • unload
  • scroll
  • resize
Note
Note: A term "fires" is generally used with events. For example: The click event fires in the moment you press a key.

Syntax for event methods

Most of the DOM events have an equivalent jQuery method. To assign a click events to all paragraph on a page, do this:

snippet
$("p").click ();

The next step defines what should happen when the event fires. You must pass a function to the event.

snippet
$("p").click(function(){
  // action goes here!!
});
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +