Iterate through a table with rows over 500 and 15 columns using jquery

Here is the challenge; how can I repeat (+ change element properties by doing this) over a table consisting of more than 500 rows using jquery / javascript? An added issue is that of IE8 browser.

I tried to use $ .each on the table for the loop ... I did it, but it slows down the damned IE and throws a script error (Error: do you want to continue this script? It may slow down your computer. Bla bla bla).

The problem is not to know how to iterate and change the properties of individual columns, but how to optimize this process.

Any help is greatly appreciated.

0
source share
2 answers

In general, if you are performing a critical task, do not use jQuery. Each $('.classname') performs at least 20 jQuery lines, and especially in the case of IE8, as well as a ton of its own iteration through the document.

There is a limit to script lines executed in IE8. By default, it executes a million lines, then the user asks if he wants to continue the script. This limit is controlled by the registry, but in the case of a web application it is not advisable to increase the value of the course.

In IE8, rendering speed is also a problem.

  • Use minimal style overall
  • Try not to set innerHTML / innerText , use createElement() and / or createTextNode() and appendChild() and / or insertBefore() instead.
  • Avoid inline styles, change class names instead, or even use direct manipulation of CSS rules.
  • Cache elements are used to the maximum when using getElementsBy/Tag/Class/Name() .
  • Use the collected collections of table.rows and table.rows[n].cells , where possible.
  • Suppose that only part of the table is shown, it makes rendering faster.
+2
source

Have you tried this

 var table = document.getElementById("mytab1"); for (var i = 0, row; row = table.rows[i]; i++) { //iterate through rows //rows would be accessed using the "row" variable assigned in the for loop for (var j = 0, col; col = row.cells[j]; j++) { //iterate through columns //columns would be accessed using the "col" variable assigned in the for loop } } 
+1
source

Source: https://habr.com/ru/post/973837/


All Articles