<script language="javascript" type="text/javascript" src="/Resources/shared/scripts/jquery/jquery.min.js"></script> 1:
2: <script language="javascript" type="text/javascript">jQuery.noConflict();
</script> 1:
2: </head>
3: <body>
4: <table id="tblCustomer" cellspacing="0" cellpadding="2" border="1" style="width: 500px;">
5: <tbody>
6: <tr id="rowHeader" style="font-weight: bold;">
7: <td>First</td>
8: <td>Last</td>
9: <td>Address</td>
10: <td>City</td>
11: <td>State</td>
12: </tr>
13: <tr>
14: <td>John</td>
15: <td>Dough</td>
16: <td>123 Main Street</td>
17: <td>Orlando</td>
18: <td>Florida</td>
19: </tr>
20: <tr>
21: <td>Jane</td>
22: <td>Dough</td>
23: <td>4367 South Washington Avenue</td>
24: <td>Bartow</td>
25: <td>California</td>
26: </tr>
27: <tr>
28: <td>Bart</td>
29: <td>Thompson</td>
30: <td>531 Townsend Circle</td>
31: <td>Atlanta</td>
32: <td>Georgia</td>
33: </tr>
34: <tr>
35: <td>Sherry</td>
36: <td>Simpson</td>
37: <td>3346 Presario Lane, Apt. 123</td>
38: <td>Seattle</td>
39: <td>Washington</td>
40: </tr>
41: <tr>
42: <td>Matt</td>
43: <td>Damon</td>
44: <td>300 Pounds Street</td>
45: <td>Boston</td>
46: <td>Massachusetts</td>
47: </tr>
48: </tbody>
49: </table>
50: <script language="javascript" type="text/javascript">
51: jQuery(document).ready(function() { 52:
53: setCssRules();
54:
55: // wire up the logic to make our function work
56: jQuery('#tblCustomer tr:not(\'#rowHeader\')').click(function() { 57:
58: // get a reference to the chosen row
59: var oRow = this;
60: // remove the row from the table
61: jQuery(this).remove();
62: // add the row to the top of the table
63: jQuery('#tblCustomer').prepend(oRow); 64: // backtrack to put the header row back at the top of chosen row
65: jQuery('#rowHeader').prependTo('#tblCustomer'); 66: // reset the CSS rules
67: jQuery(this).css('background-color', '#ffffff'); 68: setCssRules();
69: });
70:
71: });
72:
73: function setCssRules() { 74: // this would be better implemented in a CSS file
75: jQuery('#tblCustomer tr:not(\'#rowHeader\')') 76: .css('cursor', 'pointer') 77: .mouseover(function() { 78: jQuery(this).css('background-color', '#c0c0c0'); 79: })
80: .mouseout(function() { 81: jQuery(this).css('background-color', '#ffffff'); 82: });
83: }
84:
</script>