Parsing decimals into a span - Javascript jQuery

Javascript examples for jQuery:Number

Description

Parsing decimals into a span

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.5.2.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from   www .j a v  a  2s .  c o m*/
$('input').change(function () {
    var val = parseFloat($(this).val(), 10).toFixed(2);
    $('span').html(val);
});
    });

      </script> 
   </head> 
   <body> 
      <input value="123"> 
      <span></span>  
   </body>
</html>

Related Tutorials