Why is this Javascript loop taking one minute for 100 iterations?
<p>I am using the below code in my program but it seems that these few line of code is taking too much time to execute. For 100 iteration it is consuming 1 mins approx. for 200+ iteration my broser is showing a warning message that script is taking too much time. As per the scenario 500+ ids can be pushed into the array.</p>

<pre><code>for (var i = 0; i &lt; arrid.length; i++)
{
    $("#" + outerDiv + "&gt; div[id=" + arr[i] + "]").attr("class", "selected");
}
</code></pre>

<p><code>arrid</code> is an array of div ids. Outerdiv is the the parent div of all these div ids present in <code>arrid</code>. arr ids cannot be accessed directly, it has to be referenced using the parent div i.e. outerDiv.</p>
