hide/show are *very* slow

xn dx picture xn dx · Jul 28, 2011 · Viewed 7.5k times · Source

I'm currently using the hide/show functions in jQuery to help filter a table into groups from a select box.

The actual code works fine, but is incredibly slow, sometimes taking a minute or two to execute.

I switched the code so instead of hide() and show() it uses css({'display':'none'}); and css({'display':'block'}); - the speed difference is simply incredible, it now takes just seconds, but in Firefox the table data is all squashed for each row.

This isn't the end of the world since here we almost exclusively use Internet Explorer, but I was still wondering if there's a way around it since a fair amount of people (myself included) do use Firefox.

Answer

ShankarSangoli picture ShankarSangoli · Jul 28, 2011

In firefox to show/hide a table row you have to set the follwoing.

//To show
$("tr").css("display", "table-row");

//To hide
$("tr").css("display", "none");