make jquery procedure run better
<p>I have the following code:</p>

<pre><code>$('#MyDiv .TheClass').eq(TheIndex).removeClass('ClassA');
$('#MyDiv .TheClass').eq(TheIndex).removeClass('ClassB');
$('#MyDiv .TheClass').eq(TheIndex).addClass('ClassC');

$('#MyDiv .TheClass').eq(TheIndex).children().each(function () {
 //do something here
});
</code></pre>

<p>It seems I'm using the <strong>$('#MyDiv .TheClass').eq(TheIndex)</strong> line several times; how can I make this better?</p>

<p>I thought of doing</p>

<pre><code>var TheDiv = $('#MyDiv .TheClass').eq(TheIndex);

TheDiv.removeClass('ClassA');
TheDiv.removeClass('ClassB');
TheDiv.addClass('ClassC');

TheDiv.children().each(function () {
 //do something here
});
</code></pre>

<p>But I'm wondering if there's a better suggestion out there.</p>

<p>Thanks.</p>
