This strikes me as a task where creating new elements may be less gremlin-prone than cloning.
Michael Geary's "Easy DOM Creation" plugin might make it easier to write a function that creates the appropriate DOM tree branch. http://mg.to/2006/02/27/easy-dom-creation-for-jquery-and-prototype - Brian > I'm working with recipes and I want to use some jQuery goodness to clone a > DOM construct that will contain a few form fields so that adding > ingredients > is easy, and fun. I thought that it would be pretty easy to code but it's > giving me some trouble and I wanted to see if you guys could help me out. > > My HTML: > <ol id="ingList"> > <li class="ingredient"><input type="text" name="ing_01"><input > type="button" class="addIng" value="+"></li> > </ol> > > Here's the jQ code I have thus far: > $(document).ready( function(){ > $('#ingList .ingredient .addIng').click( function() { > $('#ingList > .ingredient').clone().appendTo('#ingList:last-child'); > > }); > }); > > The goal is that the user would fill the first field then click the "+" > button. Then the following would occur: > > 1) Clone current LI tag > 2) Append it to itself. > 3) Clear the value from the form field > 4) Increment the name value of the form element, ing_01, ing_02, etc. > 5) Lastly, remove the plus button from the elemet just previous to the new > one. > > I'm working with various jQ methods but I can't seem to get this working. > Does anyone have input on this? _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/