jQuery Slowness With Large Table Row Highlighting
<p>I've got this little snippet that I use for row highlighting on an XSLT page that has to use an onclick event to postback some data, but because the row isn't a link I have to make sure there's a hand cursor as well as the row being highlighted so the users understand it's clickable and what row they're on.</p>

<pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
    $('#stocks tr:not(.exclude)').css('cursor', 'hand');
    $('#stocks tr:not(.exclude)').hover(function() {
      $(this).addClass('hover');
    }, function() {
      $(this).removeClass('hover');
    });
  });
&lt;/script&gt;
</code></pre>

<p>The tables are large, typically up to 5000 rows.  When there's a large amount of rows the row highlighting used by this jQuery script goes quite slow.  I wrote the <code>tr:not(.exclude)</code> selector, but I'm thinking perhaps that's what's causing it to go slow?  Any ideas on how to speed this up?</p>

<p><strong>EDIT</strong>: I see many answers are very good, however they do not address the fact of there being over 5,000 rows at least.</p>

<p><strong>EDIT EDIT</strong>: You MUST ensure that IE7 at least has the following doctype set in order for tr:hover to work.  Mine <em>still</em> goes slow, however this must be down to something else.</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
</code></pre>
