What is SideeX
|
Smart Record and Playback Automations
|
Software Powered by SideeX
|
from : http://www.sideex.org/
分享 Linux/Apache/PHP+MySQL/Smarty/JQuery/RubyOnRails 的點點滴滴!
What is SideeX
|
Smart Record and Playback Automations
|
Software Powered by SideeX
|
$('th').click(function(){
var table = $(this).parents('table').eq(0)
var rows = table.find('tr:gt(0)').toArray().sort(comparer($(this).index()))
this.asc = !this.asc
if (!this.asc){rows = rows.reverse()}
for (var i = 0; i < rows.length; i++){table.append(rows[i])}
})
function comparer(index) {
return function(a, b) {
var valA = getCellValue(a, index), valB = getCellValue(b, index)
return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB)
}
}
function getCellValue(row, index){ return $(row).children('td').eq(index).text() }
table, th, td {
border: 1px solid black;
}
th {
cursor: pointer;
}
Country