I recently started working with jQuery. I want to improve performance for following snipet when run for 1000 times.
html schema: <table id='myTable'> <TR class="Grid_Item"> <TD></TD> ... <TD CLASS="IdCell">56</TD> ... <TD> <INPUT TYPE="HIDDEN" ID="foo" value="MYfOO" /> </TD> <TD> <INPUT TYPE="HIDDEN" ID="bar" value="MYBar" /> </TD> ... <TD></TD> ... </TR> ... <TR class="Grid_AltItem"></TR> </table> <script type="text/javascript"> var id, foo, bar = null; jQuery(".Grid_Item,.Grid_AltItem").each( function() { //begin for-each TR id = jQuery(this).find(".IdCell").text(); foo = jQuery(this).find("#foo").val(); bar = jQuery(this).find("#bar").val(); }); </script> I am parsing a table and build certain type based on vaues from each row. In above jQuery I use find function to read values. I feel that find iterate over the set of TDs and may not be efficient. I want to read TD values using its index numbers like jQuery(".Grid_Item,.Grid_AltItem").each( function() { //begin for-each TR var Id = jQuery("td:eq(2)").text(); var foo = jQuery("td:eq(8)").firstchild.attr("value"); var bar = jQuery("td:eq(9)").firstchild.attr("value"); }); but with that I get values of TDs that are 2nd, 8th and 9th from top of document and not from TR in context. How can I get the values? It would be nice to know if there is another angle to improve performance. Appreciate it much. -- View this message in context: http://www.nabble.com/jQuery-improving-performance-tf4933357s27240.html#a14120631 Sent from the jQuery General Discussion mailing list archive at Nabble.com.