O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling Events

jQuery helps you add event listeners to the objects you select. These are similar to the DOM events but are somewhat easier to work with and provide greater flexibility. In addition, jQuery defines its own events for animating the display of information. These animations make your page more appealing to users.

Let’s start by looking at the .ready() function. This is a key jQuery event that can be used to wrap code you want to execute when the DOM has fully loaded and is ready for work. You write this event as $(document).ready(function(){...}). There is also a shorthand version of this method written as $(function(){...}). The following shows an example.

$(document).ready(function () {  $('#footer').css('background-color', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required