Change div value based on textbox value using jQuery - Javascript jQuery

Javascript examples for jQuery:Form Text Input

Description

Change div value based on textbox value using jQuery

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-1.6.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from   ww w  . j  a va2s.com
var max = 10;
$('input').keyup(function() {
    var v = $(this).val();
    v = isNaN(v) ? '' : v;
    v = v > max ? max : v;
    $(this).val(v);
    $('div').html(v * 10);
});
    });

      </script> 
 </head> 
 <body> 
  <input> 
  <div></div>  
 </body>
</html>

Related Tutorials