需求: 使用頁面資料內容,點擊<th>時會遞增,遞減排序所屬<td>內容。 實作: 引用: <!--引用 dataTables css --> <link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" /> <!--引用jQuery--> <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script> <!--引用dataTables--> <script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"> html: table class給JQ_DataTable,不想排序的欄位,class給no-sort。 <table class=" JQ_DataTable "> <thead> <tr> <th class=" no-sort ">項次</th> <th>內容</th> </tr> </thead> <tbody> @for (var i = 1; i <= 10; i++) { <tr> ...