Cloning with jQuery

天涯浪子 提交于 2019-12-05 18:59:33

I have created an example here: http://jsfiddle.net/K8hhW/5/

You do not need to worry about incrementing the numbers in the brackets, the form does this automatically for you.

You don't need to specify the index [0], as long as you put [] the browser will automatically increment the index.

As for your question, here's how I would do it: http://jsfiddle.net/EJv4g/3/

Basically, I added a div.friend-boxes which wraps all friend boxes. I use jQuery to obtain the first friend box, clone it then reset the input field values (in case they were filled). I then append it to the .friend-boxes element.

You can change the append to prepend if you want it to be prepended.

Hope this helps!

  • Christian
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!