html - Cloning 2 similar elements in jquery without using a new div -


I have a form with 2 dropdowns and a text box, I have to clone them all, once they are 5 divis To limit and also to increase the ID or name, I can do this by using two different elements in a div, but at the same time there is a problem with two elements because it has the same ID for both Takes. I used

my html code:

  & lt; Div id = "element" & gt; & Lt; Div id = "ouuter_00" & gt; & Lt; Select name = "type" id = "type_00" disabled = "disabled" category = "edit" & gt; & Lt; Option value = "artist type" selected = "selected" & gt; Artist type & lt; / Option & gt; & Lt; Option value = "singer" & gt; Singer & lt; / Options & gt; & Lt; Option value = "actor" & gt; Actor & lt; / Options & gt; & Lt; Option value = "fighter" & gt; Fighter & lt; / Options & gt; & Lt; Option value = "Editor" & gt; Editor & lt; / Options & gt; & Lt; Option value = "author" & gt; Author & lt; / Options & gt; & Lt; / Select & gt; & Amp; Nbsp; & Amp; Nbsp; & Lt; Select Name = "ASubType" id = "ASUUBTY_00" disabled = "disabled" class = "edit" & gt; & Lt; Option value = "artist subtype" selected = "selected" & gt; Artist subtype & lt; / Option & gt; & Lt; Option value = "actor" & gt; ----- Actor ----- & lt; / Options & gt; & Lt; Option value = "Comedian" & gt; Comedian & lt; / Option & gt; & Lt; Option value = "hero" & gt; Hero & lt; / Options & gt; & Lt; Option value = "villain" & gt; Villains & lt; / Options & gt; & Lt; Option value = "Assist cast" & gt; Assist Cast & lt; / Options & gt; & Lt; Option value = "singer" & gt; ----- Singer ----- & lt; / Options & gt; & Lt; Option value = "People" & gt; People & lt; / Options & gt; & Lt; Option value = "pop" & gt; Pop & lt; / Option & gt; & Lt; Option value = "movie" & gt; Movie & lt; / Option & gt; & Lt; / Select & gt; & Amp; Nbsp; & Amp; Nbsp; & Lt; Input type = "text" placeholder = "quantity" name = "quantity" id = "Quantity_00" disabled = "disabled" class = "edit" onkeypress = "return number only (this, event)" title = "you only 3 "Maxlength =" 3 "/> Enter the number up to & lt; / Div & gt; & Lt; / Div & gt;    

This is your answer:

  var counter = 1; Click $ ("# BtnAdd") (function () {if (counter & lt; = 4) {counter ++ var inner contact = 0; $ ('# element'). (". Internal divis: last") .appendTo ("# element"). (Select '') Each (function () {innerCounter ++; $ (this) .attr ({'name': 'ddl_' + counter + innerCounter, 'id': 'Ddl_' + Counter + innerCounter})}) Next ('Input') .attr ({'name': 'inText_' + counter, 'id': 'inextext' 'counter)}}}});   



Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -