JQuery: find and replace of attribute values
<p>I am having difficulty performing a find and replace of attribute values.</p>

<p>Consider this html:</p>

<pre><code>&lt;tr id="rules[0]"&gt;
    &lt;td&gt;
        &lt;input id="rules0.isActive1" name="rules[0].isActive" type="checkbox" value="true"/&gt;&lt;input type="hidden" name="_rules[0].isActive" value="on"/&gt;
    &lt;/td&gt;
    &lt;td&gt;
        &lt;select id="rules0.leftCondition.name" name="rules[0].leftCondition.name"&gt;
            ...
        &lt;/select&gt;
    &lt;/td&gt;
</code></pre>

<p>I am looking to update each 's name attribute with the appropriate count e.g. rules[0].isActive is updated to rules[10].isActive</p>

<p>I am using this JQuery snippet:</p>

<pre><code>$(newRow).find('[id*="rules"]').each(function(){
    // Update the 'rules[0]' part of the name attribute to contain the latest count 
    this.name.replace('rules\[0\]','rules\[$count\]');
}); 
</code></pre>

<p>where newRow is a variable holding the entire  block and count holds the latest counter value.
However, when I debug this code it seems that "this.name" is undefined.</p>

<p>Where am I going wrong here?</p>

<p>Thanks</p>
