Two equal jQuery scripts with different behavior
<p>I have an script that when click a button do many things and also rename some elements, so at first I use first script and I see sometimes work, sometimes not, so change it to second script and all time worked perfectly, but there is a question. is this two scripts do same? what is the difference, rather than all of my script I just replace first one with second one.</p>

<p>This is first script </p>

<pre><code>$(CloneTarget).find(':input[name="' + MainName + '"]').attr('name', NewSelectName);
</code></pre>

<p>And second one:</p>

<pre><code>$(CloneTarget).find(':input').each(function () {
    if ($(this).attr('name') == MainName) {
        $(this).attr('name', NewSelectName);
    }
});
</code></pre>

<p>Where is the problem with first one?</p>

<p><strong>Edit</strong></p>

<p>Also I use this:</p>

<pre><code>    $(CloneTarget).find(':input[id="' + MainId + '"]').attr('id', NewSelectId);
</code></pre>

<p>And every thing worked fine I am really confused here, I must mention <code>MainName</code> and <code>MainId</code> are so similar like: <code>MainName = Model.Phones[0]</code> and <code>MainId = Model_Phones[0]</code> is the difference is about <code>.</code> character or any other things?</p>
