I am using this code for cloning. 

1. I want to modify this code when I click on the **clone** button it's cloning again and again **clone** and **remove** button for every new generated dynamic div.
2. When I click on the **clone** button the first time, it clone the same div using same id **id =clonedInput1**, after that it start increment.

You can find a working version here <http://jsfiddle.net/shalucosmic/FEpMk/7/>

```
  <script type="text/javascript">
  $(document).ready(function(){
        //jQuery(this).parent(".clonedInput")
           var regex = /^(.*)(\d)+$/i;
           var cloneIndex = $(".clonedInput").length;

           $("button.clone").live("click", function(){

           $(this).parents(".clonedInput").clone().appendTo("body").attr("id",  "clonedInput" +  cloneIndex)
           .find("*").each(function() {
            var id = this.id || "";
            var name = this.name || "";

            var match = id.match(regex) || [];

           var matchname = name.match(regex) || [];
           if (match.length == 3) {
            this.id = match[1] + (cloneIndex);
           }
          if (matchname.length == 3) {
            this.name = match[1] + (cloneIndex);
          }
 });
cloneIndex++;

});
$("button.remove").live("click", function(){
   $(this).parents(".clonedInput").remove();
});

});

```

```
  <div id="clonedInput1" class="clonedInput">
   <input type="text" name="contributer1" value="" id="contributer1"/>

   <div class="actions">
    <button class="clone">Clone</button> 
    <button class="remove">Remove</button>
   </div>
 </div>

```