Create a new text field when click on previous text field - Javascript jQuery

Javascript examples for jQuery:Text

Description

Create a new text field when click on previous text field

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.9.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//ww w.  j a  va2s . c  o  m
$('form').on('click', 'input:last', function() {
   $(this).after( $(this).clone().attr( 'id', 'textfield_' + ++this.id.split('_')[1] ) );
})
    });

      </script> 
 </head> 
 <body> 
  <form> 
   <input type="text" id="textfield_1"> 
  </form>  
 </body>
</html>

Related Tutorials