Javascript examples for jQuery Method and Property:keypress
Keypress Event - Javascript/Jquery
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> </head> <body> <h1 align="center"></h1> <script> var time=10;//from w w w . j a v a 2s . com var timer; $('body').keypress(function() { timer=setInterval(function(){ if(time<=0) clearInterval(timer); $('h1').html(time); time--; },1000) $(this).unbind('keypress'); }); </script> </body> </html>