jQuery clone() with increment value and input field issues
<p>I have 2 main issues with my clone() script.</p>

<ol>
<li>Whenever I clone a div, I'd like to change the text with the increment value. Eg, the new block should have the title "Block 2"... and so on. </li>
<li>When I click on the radio button and clone it, the cloned block still has the radio selected. I already have the value set to empty value in the script but it does not seem to be working on the first clone.</li>
</ol>

<p>HTML:</p>

<pre><code>&lt;div&gt;
    &lt;div id="mydiv"&gt;
        &lt;div class="title"&gt;Block 1&lt;/div&gt;
        &lt;div&gt;
            &lt;input type="radio" name="blockoption" value="left"&gt; Radio 1&lt;br /&gt;
            &lt;input type="radio" name="blockoption" value="right"&gt; Radio 2&lt;br /&gt;
            &lt;select&gt;
                &lt;option selected="selected"&gt;Select&lt;/option&gt;
                &lt;option&gt;Option 1&lt;/option&gt;
                &lt;option&gt;Option 2&lt;/option&gt;
                &lt;option&gt;Option 3&lt;/option&gt;
            &lt;/select&gt;&lt;br /&gt;
            &lt;input type="text" name="blocktext" /&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;input id="addbutton" type="button" value="Add Block" /&gt;&amp;nbsp;&lt;input id="removebutton" type="button" value="Remove Block" /&gt;
</code></pre>

<p>jQuery:</p>

<pre><code>$("#addbutton").click(function () {
var inc = $('#mydiv').siblings().length;
$('#mydiv:first-child').clone().insertAfter('#mydiv:last-child').find('input').val('');
$('#mydiv').find('.title').each(function() {
    $(this).text().replace(/\d+/, inc+2);
});
});

$("#removebutton").click(function () {
var inc = $('#mydiv').siblings().length;
if (inc &gt; 0) {
    $('#mydiv:last-child').remove('#mydiv');
    $('#mydiv').find('.title').each(function() {
        $(this).text().replace(/\d+/, inc-2);
    });
}
});
</code></pre>

<p><strong>See the code in action <a href="http://jsfiddle.net/Ms8Ws/1/" rel="nofollow">here</a>.</strong></p>
