JavaScript
  Home arrow JavaScript arrow Page 2 - More Mouse and Keyboard Events with the jQ...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

More Mouse and Keyboard Events with the jQuery JavaScript Library
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2009-09-02

    Table of Contents:
  • More Mouse and Keyboard Events with the jQuery JavaScript Library
  • Review: mouse overs and keydown events with jQuery
  • Manipulating a keypress event with the keypress() method
  • Using the keyup() method

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    More Mouse and Keyboard Events with the jQuery JavaScript Library - Review: mouse overs and keydown events with jQuery


    (Page 2 of 4 )

    In case you haven't had the chance to read the previous tutorial of the series, where I explained how to handle mouse overs and keydown events with the jQuery library, below I listed a couple of examples that show how to perform these specific tasks. Here they are:

    (example on handling a 'mouseover' event with jQuery)


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <title>Basic example on using jQuery with mouseover event</title>

    <style type="text/css">

    body{

    padding: 0;

    margin: 0;

    background: #fff;

    }

    h1{

    font: 24px bold Arial, Helvetica, sans-serif;

    color:#000;

    }

    </style>

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

    <script type="text/javascript">

    $(document).ready(function(){

    $("a").mouseover(function(){

    alert('Redirecting to Devshed.com now!');

    });

    });

    </script>

    </head>

    <body>

    <h1>Basic example on using jQuery with mouseover event</h1>

    <a href="http://www.devshed.com/">Visit Devshed.com now!</a>

    </body>

    </html>



    (example on handling a 'keydown' event with jQuery)


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <title>Basic example on using jQuery with keydown event</title>

    <style type="text/css">

    body{

    padding: 0;

    margin: 0;

    background: #fff;

    }

    h1{

    font: 24px bold Arial, Helvetica, sans-serif;

    color:#000;

    }

    </style>

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

    <script type="text/javascript">

    $(document).ready(function(){

    $("a").keydown(function(){

    alert('Redirecting to Devshed.com now!');

    });

    });

    </script>

    </head>

    <body>

    <h1>Basic example on using jQuery with keydown event</h1>

    <a href="http://www.devshed.com/">Visit Devshed.com now!</a>

    </body>

    </html>

     

    These were really simple to code and grasp, right? As you can see, the pair of examples listed above demonstrate in a nutshell how to build basic JavaScript applications that respond to mouse overs and keydown events. Of course, in this case, the applications will display a couple of alert boxes on screen in response to those events. This simple concept, however, can be easily applied when working with real-world projects.

    So far, so good. At this point, you hopefully realized that handling mouse and keyboard events by way of the jQuery library is simple. So, what comes next? Well, as I mentioned in the introduction, in the section to come I'm going to provide you with another hands-on example to demonstrate how to process keypress events by using a brand new method of the jQuery package.

    To see how this will be achieved, please click on the link that appears below and keep reading.

    More JavaScript Articles
    More By Alejandro Gervasio


       · This chapter of the series explains how to utilize the jQuery library for processing...
       · I love the print version -- really the only readable version.I seriously doubt...
       · Thanks for the comments, as I really appreciate your words and the time you took to...
     

    JAVASCRIPT ARTICLES

    - Using jQuery to Preload Images with CSS and ...
    - Using Client-Side Scripting to Preload Image...
    - Removing Non-Semantic Markup when Preloading...
    - Using the Display CSS Property to Preload Im...
    - Preloading Images with CSS and JavaScript
    - Scaling and Moving Web Page Elements with th...
    - Fading, Hiding and Sliding HTML Elements wit...
    - Toggling CSS Properties with the GX JavaScri...
    - Cancel, Queue and Pause Animations with the ...
    - Producing Elastic Effects with the GX JavaSc...
    - Moving Divs Diagonally with the GX JavaScrip...
    - Moving Elements Vertically and Horizontally ...
    - Making Bouncing Effects in Parallel with the...
    - Creating Bouncing Effects with the GX JavaSc...
    - Manipulating Background Colors with the GX J...







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek