Traversing Table with jQuery
<p>I have a table with an HTML attribute on the TR element titled "data-order" which simply holds an integer indicating the order in which to sort the table (descending). Right now the code only checks the row ahead of the TR clicked - what I'm attempting to do is to get it to scan all rows ahead of its position in the table and once it finds a number greater than (not greater than or equal to) then call the swaprow function...  </p>

<p>Here is the javascript used to move the row up.</p>

<pre><code>function adjustRank(id, e) {
    var url = "/ajax/moveup/" +  aid;
    var row = $(e).closest("tr").get(0);
    var prevRow = $(row).prev().get(0);
    var moveUp = false;
    var prevRowOrder = parseInt($(prevRow).attr("data-order"));
    var rowOrder = parseInt($(row).attr("data-order"));

    $.ajax({
        type: "POST",  
        url: url,
        data: {aid: aid},
        dataType: "json",
        success: function () 
        { 
            if(rowOrder + 1 &gt; prevRowOrder)  // think this is where I need to traverse the table
                swapRows(row, prevRow);
        },
        failure: function () { alert("Error processing request."); }
    });
}
</code></pre>

<p>and here are a couple of items in the table for example:</p>

<pre><code>&lt;table id="listings" style="min-height:150px; width:100%;"&gt;
    &lt;tr id="1" data-order="11"&gt;&lt;td&gt;1&lt;/td&gt;&lt;td align="left"&gt;&lt;span onclick="adjustRank('ace93485-cea5-4243-8294-9f3d009aba3d', this)" style="cursor:pointer;"&gt;Lindsey Vonn&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr id="2" data-order="6"&gt;&lt;td&gt;2&lt;/td&gt;&lt;td align="left"&gt;&lt;span onclick="adjustRank('9f83aed6-b99a-4674-a8b7-9f3d009aba38', this)" style="cursor:pointer;"&gt;Al Horford&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr id="3" data-order="5"&gt;&lt;td&gt;3&lt;/td&gt;&lt;td align="left"&gt;&lt;span onclick="adjustRank('d48a52bd-17e9-4631-9a2e-9f3d009aba39', this)" style="cursor:pointer;"&gt;Derek Jeter&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
</code></pre>
