Handling Mouse Overs and Keyboard Events with the jQuery JavaScript Library
Welcome to the third part of an eight-part series introducing the jQuery JavaScript library. This series provides you with a quick overview of the most important features that come packaged with the jQuery JavaScript framework. You'll learn how to manipulate web pages via the DOM, handle different mouse and keyboard events, develop Ajax applications, and create eye-popping effects.
Handling Mouse Overs and Keyboard Events with the jQuery JavaScript Library - Using the mouseover() method (Page 3 of 4 )
In the previous section, I reintroduced a pair of examples aimed at illustrating how to utilize the “mouseup()” and “mousemove()” methods bundled with the jQuery library to handle these mouse events with extreme ease.
I’m only scratching the surface when it comes to exploring the event handling capacities provided by this library. It's armed with other methods that can be utilized to process, for instance, mouse overs and keyboard actions.
Thus, to demonstrate how jQuery can be used to handle the aforementioned mouse overs, below I coded another example, which will display an alert box on screen each time a user places the mouse over a sample link.
Here’s how the example in question looks:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
If you ever thought that handling mouse overs with jQuery was a difficult process, then I’m afraid that you were wrong! As you can see from the above example, I used a brand new method, not surprisingly called “mouseover(),” to display an alert box each time a user places the mouse over the link that points to “Devshed.com.” Try the previous script for yourself, and you’ll see that it works like a charm!
All right, after you’ve examined the prior example in detail, I assume that you learned how to use the handy “mouseover()” method to handle mouse overs with jQuery. Next, we'll see which methods are provided by the library to handle specific keyboard events.
This interesting topic will be discussed in depth in the section to come, so go ahead and read the next few lines. I’ll be there, waiting for you.