jQuery TablesTorter- 링크를 클릭하여 정렬합니다
-
19-09-2019 - |
문제
jQuery Tablesterter를 사용하여 테이블을 정렬하고 모든 것이 예상대로 작동합니다. 내가하고 싶은 것은 "정렬별로"라인을 따라 무언가를 말하는 내 테이블 위에 링크를 추가하는 것입니다. 사용자가 링크를 클릭하면 "가격"열을 정렬하기를 원합니다. 또한 다시 클릭하면 가격을 다른 방식으로 정렬합니다. 이게 가능해?
감사! 마노 즈
해결책
$(document).ready(function() {
$("table").tablesorter();
$("#trigger-link").click(function() {
// set sorting column and direction, this will sort on the first and third column the column index starts at zero
var sorting = [[0,0],[2,0]];
// sort on the first column
$("table").trigger("sorton",[sorting]);
// return false to stop default link action
return false;
});
});
제휴하지 않습니다 StackOverflow