Shift select table rows
<p>I know this question has been asked a lot but there is really no definite answer that I can find.
Here is my code.  Basically I have everything set up.  I'm just lost on where to get the rows of a table by index.  I've tried the .index function but I that's not working.  I'm trying to do something like <code>$('#pkgLineTable').index(i).addClass('row_selected');</code></p>

<p>But that's not working correctly.  Any help would be great.  Thank you very much.</p>

<pre><code>var lastSelected;

$('#pkgLineTable tr').live('click', function(event) {         

    var tableRow = $(this).closest("tr").prevAll("tr").length + 1;      
    if ($(this).hasClass('row_selected')) {
        $(this).removeClass('row_selected');       
    }
    else {           
        $(this).addClass('row_selected');         
    } 

    if (event.shiftKey) { 
        var table = $('#pkgLineTable');        


        var start = Math.min(tableRow, lastSelected);
        var end = Math.max(tableRow, lastSelected);                 

        for (var i = start; i &lt; end; i++) {
            //$(this).parent().parent().addClass('row_selected'); 
        }

    } else {        

        lastSelected = $(this).closest("tr").prevAll("tr").length + 1;
    }
</code></pre>

<p>My start and end values are correct.  If you select the 2 row and the 5 row you get back 2 and 5.  It then iterates 2 - 5.  I need to add a class to the rows 2 - 5.</p>

<p>Edit I used this:</p>

<pre><code>    for (var i = start; i &lt; end; i++) {
            $('#pkgLineTable').each(function() {
                $(this).find("tr").eq(i).addClass('row_selected');    
            });
        }
</code></pre>

<p>That's probably not the best way to do it.</p>
