javascript - cloning a form with jquery and remove attributes -


is possible clone form without disturbing functionality ?
indeed, id of form duplicate. 2 dom objects same id forbidden.

<form id='originalform' name='originalform' enctype='multipart/form-data' action=''>      <input id='firstname' name='firstname' type='text'/>      <input id='lastname' name='lastname' type='text' />      <input id='photo' name='photo' type='file' /> </form>   ...   var copyform = jquery('#originalform').clone();   var e = copyform.find(':input').not(':file'); e.each(function()   {   jquery($this).removeattr('name'); } 

var originalform = jquery('#originalform'); //clone form var newform = originalform.clone();  //change form id newform.attr('id', 'newid');  //remove `name` attr non file inputs newform.find('input:not(:file)').removeattr('name');  //add new form page after old 1 originalform.after(newform); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -