Now there's a trolling subject if I've ever seen one.

I don't think the looping mechanism itself is slow. Probably your "some
manipulation" part is what's slowing you down so bad.

Here's a quick little test, performed at jquery.com using firebug console:

>>> for(var i = 0; i < 1000; i++) {$('body').append('<div
class="timetest">foo</div>');}
[body]
>>> console.time('select'); var $testers = $('div.timetest');
console.timeEnd('select');
select: 37ms
>>> console.time('each'); $testers.each(function() {}); console.timeEnd
('each');
each: 3ms

Also, it's possible your initial selection is slow. I imagine having tbody
in there isn't helping at all, and is probably making it slower. "#tableId
tr" or even better, "#tableId > tbody > tr" would probably be faster.

--Erik


On 9/18/07, Potluri <[EMAIL PROTECTED]> wrote:
>
>
>
> Hi,
>   looping with jquery is quite slow, but still I want to continue with
> jquery looping(not custom looping) for reasons I can't explain right now.
> In my scenario I've to loop through rows of table and update the sequence
> of
> rows on table dynamically.
>
> suppose I've table with id "tableId".
>
> <table id="tableId">
> <tr>
> <th>sq </th>
> <th>name </th>
> <th>ID </th>
> </tr>
> <tbody>
> <tr>
> <td class="sq">sq </td>
> <td>name </td>
> <td>ID </td>
> </tr>
> <tr>
> <td>sq </td>
> <td>name </td>
> <td>ID </td>
> </tr>
> <tr>
> <td>sq </td>
> <td>name </td>
> <td>ID </td>
> </tr>
> </tbody>
> </table>
>
> $("#tableId tbody tr")
> .each(function(){
>
> some manipulation on table colomns...
>
> });
>
> This looping is taking 3-4 secs for table with 300 rows..
> Can any one tell alternate way of looping and manipulating the table
> cols..
>
> Thanks in advance..
> --
> View this message in context:
> http://www.nabble.com/jquery-looping-is-slow-tf4477318s15494.html#a12766732
> Sent from the JQuery mailing list archive at Nabble.com.
>
>

Reply via email to