Print keyup element value - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:keyup

Description

Print keyup element value

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-2.0.0b1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//w ww .  j  a  va  2s  .  c o m
var prevVal = '';
$('.someClass').on('keypress', function (e) {
    prevVal += String.fromCharCode(e.which);
    console.log(prevVal);
}).on('keyup', function() { prevVal = $(this).val() });
    });

      </script> 
 </head> 
 <body> 
  <input class="someClass">  
 </body>
</html>

Related Tutorials