functionAddli () {varlistnum=$ (". Divlist"). length; varnum= ListNum = = 0? 1:listnum+1 ; Console.log (num); varDivobj = ' <div class= "divlist" ><input class= "Small_input" placeholder= "Start Year" name= "Start_year ' +num + '"/> <input class= "Small_input" placeholder= "End Year" name= "End_year ' +num + '"/><input class= "Small_input" placeholder= "Country" name= "Country ' +num + '"/><input class= "Small_input" placeholder= "Project Amount" name= "Item_amount" +num + ' "/><input class=" Small_input "placeholder=" project name "Name=" Item_name ' +num + ' "/></div> ' $('. Main_business '). Append (Divobj); varinput_sum_val=$ (". Input_sum"). Val () $ (". Input_sum"). Val (+ +input_sum_val); }
<DDstyle= "Height:auto;"> <label>Main business</label> <inputclass= "Input_sum"type= "hidden"name= "Max"value= "1" /> <Divclass= "Main_business"> <inputclass= "Small_input"placeholder= "Start Year"><inputclass= "Small_input"placeholder= "End Year"> <inputclass= "Small_input"placeholder= "Country"><inputclass= "Small_input"placeholder= "Project Amount"><inputclass= "Small_input"placeholder= "Project Name"> </Div> <Buttononclick= "Addli ()">Add</Button> </DD>
jquery dynamic Add input,name value self-increment