An HTML file and a JS file together, in the HTML file to introduce JS file, with jquery for the <a> tag to add a click event, the event only need to write a append function.
HTML Source:
1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Title</title>6 <Scriptsrc= "Jquery-2.2.2.min.js"></Script>7 <Scriptsrc= "Add.js"></Script>8 </Head>9 <Body>Ten <formMethod= "POST"Action=""> OneFeatured List:<ahref="#"ID= "Addmoretextbox" >Add Input Box</a> A <BR/> - <DivID= "Inputswrapper"> - <inputtype= "text"name= "news[]"ID= "News_1"value= "Text 1"><BR/><BR/> the <inputtype= "text"name= "news[]"ID= "News_2"value= "Text 2"><BR/><BR/> - <inputtype= "text"name= "news[]"ID= "News_3"value= "Text 3"><BR/><BR/> - </Div> - <inputtype= "Submit"name= "Edit"value= "Submit"> + </form> - </Body> + </HTML>
jquery Source code:
1$ (document). Ready (function () {2 varInputcount=3;3$ ("#AddMoreTextBox"). Click (function(e)4 {5inputcount++;6$ ("#InputsWrapper"). Append (' <label></label><input type= "text" Name= "news[]" id= "News_ ' + Inputcount + ' "value=" Text ' + inputcount + ' "/><br/><br/> ');7 });8});
Html+jquery implement dynamic Add <input> input Box