I want to receive alerts when I press a key.
I tried:
$('body').live('keyup', function() { alert('testing'); });
But that doesn't work, maybe because of the selector?
UPDATE:
Here is my code:
<!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=UTF-8"/> <title>TODO supply a title</title> <script type="text/javascript" src="../system/media/js/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { $('body').live('keyup', function() { alert('testing'); }); }); </script> </head> <body> <p> TODO write content </p> </body> </html>
It does not warn me when I press something, although it works when I replace keyup with mouseover and hover over TODO write content
Why doesn't it work?
source share