javascript - inserting a row on click jquery -


I am struggling to explain why my code is not working, I have a text field, 2 checkboxes and One row has an add button. I have 4 rows on the load, I have a hyperlink when clicked, should add a new row at the end of the table Adding my code line Alternatively the first row starts with my last row 4 which is the cloning I am doing I'm getting the sequence when clicking on the link 1,4,2,4,3,4,4,4

I do not know where I'm making a mistake, I banging my head I've been in the last 4-5 hours for

  & lt; Table id = "setting" & gt; & Lt; Tr & gt; & Lt; Td> & Lt; Input name = "name_1" type = "article" /> gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "checkbox" /> & Lt; / TD & gt; & Lt; Td> & Lt; Input type = "checkbox" /> & Lt; / TD & gt; & Lt; Td> & Lt; Input type = "button" /> & Lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; Td> & Lt; Input name = "name2" type = "text" /> gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "checkbox" /> & Lt; / TD & gt; & Lt; Td> & Lt; Input type = "checkbox" /> & Lt; / TD & gt; & Lt; Td> & Lt; Input type = "button" /> & Lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; Td> & Lt; Input name = "name_3" type = "text" /> gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "checkbox" /> & Lt; / TD & gt; & Lt; Td> & Lt; Input type = "checkbox" /> & Lt; / TD & gt; & Lt; Td> & Lt; Input type = "button" /> & Lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; Td> & Lt; Input name = "name_4" type = "text" /> gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "checkbox" /> & Lt; / TD & gt; & Lt; Td> & Lt; Input type = "checkbox" /> & Lt; / TD & gt; & Lt; Td> & Lt; Input type = "button" /> & Lt; / Td> & Lt; / Tr & gt; & Lt; / Table & gt; $ ('# Add'). ("Click", function (e) {e.preventDefault (); e.stopPropagation (); $ clone = $ ('# settings tbr'). Filter (": last") .clone (true) .inertAfter ('# Settings ttr'). Filter (": last"). Val ('');   

I did not work for one of the following, I do not know That's why

  $ ('# settings tbody tr: last'). Clone (true) .inertAfter ('Val (' ');    

You have Tbody is not , but you can get it in jQuery Using:

  & lt; table Id = "setting" & gt; // & lt; ------------------ ----- disappear here & lt; tr & gt; & lt; td & gt; & lt; input name = "name_1" type = "text" /> gt; & lt; / td & gt; ... .............. $ ('# & lt; Portlet: Namespace / & gt; Settings TD tr: Last') // ------------- ------------- ^^^^^ ------------ It is not   

Instead you try it Can:

  $ ('# & lt; Portlet: namespace / & gt; Settings tr: last ')   

Update:
  $ (' # settings TDR ') // ------- - ^ ----------------- It messes up   

wrong ID selected use settings instead < Code> Settings :

  $ ('# setting tr: last-child'). Clone () InsertAfter ('#settings tr: last'); Another update:  
  $ ('# add')) (function (e) {var $ cln $ Cln.find (': text') Attr ('id', 'textbox' + $ ('#settings tr: last-child') = $ ('#transfer tr: last-child'). ('' Checkbox ''). Each (function (i, v) {$ (this) .attr ('id', 'check' + $ ('ft (' id ',' btn '+ 1). $ ('# Setting tr: last-child'). $ Cln.insertAfter ('#settings tr: last'); console.log ($ cln.find (': text'). Attr ('id '' + '& Lt; === & gt;' + $ cln.find (': checkbox: eq (0)'). Attr ('id') + '& lt; === & gt;' + $ Cln address (': checkbox: eq (1)'). Attr ('id'));});    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -