Increment input field value with jQuery - Javascript jQuery

Javascript examples for jQuery:Form Input

Description

Increment input field value with 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://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from   ww w . java  2s  . c om*/

var $input = $('#counter');
$input.val( +$input.val() + 1 );

    });

      </script> 
   </head> 
   <body> 
      <input id="counter" type="text" name="counter" value="1">  
   </body>
</html>

Related Tutorials