javascript add input

Solutions on MaxInterview for javascript add input by the best coders in the world

showing results for - "javascript add input"
Robin
26 May 2016
1<script>
2$(document).ready(function() {
3    var max_fields = 10;
4    var wrapper = $(".container1");
5    var add_button = $(".add_form_field");
6
7    var x = 1;
8    $(add_button).click(function(e) {
9        e.preventDefault();
10        if (x < max_fields) {
11            x++;
12            $(wrapper).append('<div><input type="text" name="mytext[]"/><a href="#" class="delete">Delete</a></div>'); //add input box
13        } else {
14            alert('You Reached the limits')
15        }
16    });
17
18    $(wrapper).on("click", ".delete", function(e) {
19        e.preventDefault();
20        $(this).parent('div').remove();
21        x--;
22    })
23});
24  </script>
25<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
26<div class="container1">
27    <button class="add_form_field">Add New Field &nbsp; 
28      <span style="font-size:16px; font-weight:bold;">+ </span>
29    </button>
30    <div><input type="text" name="mytext[]"></div>
31</div>
queries leading to this page
insert input javascriptadd an input field javascriptjavascript add input to a formjavascript add new input fieldhow to add input box in javascriptadd new input jsjs add an input to htmladd an input field jsadd input to form javascriptadd input to html via javascriptjquery add text in inputadding input value in javascriptadd input field in javascripthow to insert a input tag in javascriptadding input with jsadd inputs to form javascriptadd input values javascriptadding input to functions javascript 5bjs add input to htmlhow to add input to html javascriptadd inputjavascript add element inputadding an input box with jshow to insert input in function javascripthow to add input in javascriptjs add input html elementjs add input to formjavascript add input to formjs add input elementadd element input javascriptadd inputs in javascriptadd input element in javascriptinsert input jsjs add inputadd input element javascriptadd input box in javascriptusing javascript to add new inputadd input html javascriptjavascript add inputhow to add input field in html using javascriptadd input in javascriptadd an html element in input javascriptjavascript add input boxjavascript add input to a functionput input in a function javascriptjs form add input add input javascriptjs add input fieldadd from input function javascriptadd input type javascriptadd input jshow to add a input box in javascripthow to add inputs javascriptdom add inputjavascript add element in inputadding input to functions javascriptjavascript add input