Add row to a table with Jquery,but don't need its value [duplicate]



<strong>Possible Duplicate:</strong><br /><a href="https://stackoverflow.com/questions/3576565/how-can-i-clone-a-row-in-a-table-without-cloning-the-values-of-the-input-elements" rel="nofollow">How can I clone a row in a table without cloning the values of the input elements inside it?</a>


i am trying to add a row to a table.i found that we can use clone . my table has two text boxes in it in two different tr's .cloning the last row is also duplicating the values in my textbox's which i don't want ?Any ideas ???

my code

$("#table-1 tr:last").clone();


may be somthing like this

$("#table-1 tr:last").clone().find('input[type=text]').val('');


If you want to add a row with the inputs, but not the values, you could do something like what you have, and just clear the values:

var row = $("#table-1 tr:last").clone(); row.find( 'input' ).each( function(){ $( this ).val( '' ) }); row.appendTo( "#table-1" )


Just clear the input fields after cloning :

var row = $("#table-1 tr:last").clone().find(':input').val('').end(); // then add the row at the end of the table $("#table-1").append(row);


  • How do I import data in one pillar file from another?
  • Database for Full Text Search and 200M+ Records
  • “Big” scrollbar for spinner
  • How to keep from duplicating path variable in ksh
  • Forcing a context switch from the userland on Linux?
  • Is it safe to cast void pointer to char pointer pointer
  • Suspending event listeners
  • AngularJS : transclude ng-repeat inside directive
  • Merge list of objects into consistent list based on common matching attribute in Python
  • Insert records if not exist SQL Server 2005
  • OpenCV Python: Draw minAreaRect ( RotatedRect not implemented)
  • WP7 difficulties binding data to listbox itemssource - won't refresh
  • Simplify where clause with repeated associated type restrictions
  • Why does the font in these TD elements render at different sizes?
  • Unique Permutations - with exceptions
  • garbled css name when styling within UiBinder
  • How to open html table in xls on click of a button
  • Cloud Code function running twice
  • Scala multiline string placeholder
  • Read a local file using javascript
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • MySQL WHERE-condition in procedure ignored
  • When should I choose bucket sort over other sorting algorithms?
  • what is the difference between the asp.net mvc application and asp.net web application
  • Web-crawler for facebook in python
  • align graphs with different xlab
  • Unanticipated behavior
  • Matrix multiplication with MKL
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • trying to dynamically update Highchart column chart but series undefined
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • Can't mass-assign protected attributes when import data from csv file
  • Binding checkboxes to object values in AngularJs
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • java string with new operator and a literal