Question: I want to move the child rows with the parent while I sort the parent row. I use this js to sort my table data. my html is like
<table> <tr class="parent"> <th id="apple">Apple</th> <th id="orange">Orange</th> <th>Banana</th> </tr> <tr class="parent"> <td>Apple</td> <td>Orange</td> <td>Banana</td> </tr> <tr class="child"> <td>Apple 1</td> <td>Orange 1</td> <td>Banana 1</td> </tr> <tr class="child"> <td>Apple 2</td> <td>Orange 2</td> <td>Banana 2</td> </tr> <tr class="parent"> <td>Table</td> <td>cHAIR</td> <td>Mouse</td> </tr> <tr class="child"> <td>Table 1</td> <td>cHAIR 1</td> <td>Mouse 1</td> </tr> <tr class="child"> <td>Table 2</td> <td>cHAIR 2</td> <td>Mouse 2</td> </tr> </table>
js is as follows:
jQuery.fn.sortElements = (function(){ var sort = [].sort; return function(comparator, getSortable) { getSortable = getSortable || function(){return this;}; var placements = this.map(function(){ var sortElement = getSortable.call(this), parentNode = sortElement.parentNode,
Adding another JS:
$('#apple, #orange') .each(function(){ var th = $(this), thIndex = th.index(), inverse = false; th.click(function() {
javascript jquery ajax solr
Era
source share