<span style="font-size:18px;">//分頁控制項 $(document).ready(function () { var pageSize = 10; var index; //分頁控制項 $.jqPaginator('#pagination2', { pageSize: pageSize, totalCounts: 10, //總條數 visiblePages: 10, currentPage: 1, prev: '<li class="prev"><a href="javascript:;">上一頁</a></li>', next: '<li class="next"><a href="javascript:;">下一頁</a></li>', page: '<li class="page"><a href="javascript:;">{{page}}</a></li>', onPageChange: function (num, type) { index = num; getData(); } }); function getData() { $.post("@Url.Action("SelectBookStudent")", { "pageSize": pageSize, "pageIndex": index, "type": "@(Request.QueryString["type"] ?? "False")" }, function (result) { var html = ""; if (result == null || result.list.length > 0) { $('#pagination2').jqPaginator('option', { totalCounts: result.total }); total = result.list.length; $.each(result.list, function (i, item) { //時間格式轉換 var pa = /.*\((.*)\)/; var StartDate = item.TKBeginDate.match(pa)[1].substring(0, 10); //轉換起始時間格式 var EndDate = item.TKEndDate.match(pa)[1].substring(0, 10);//轉換終止時間格式 var TKStartDate = getTime(StartDate); //起始日期 var TKEndDate = getTime(EndDate); //終止日期 var TKTestDate = TKStartDate.substring(0, 10); //截取日期 var TKBeginTime = TKStartDate.substring(11, 19); //截取起始時間 var TKEndTime = TKEndDate.substring(11, 19);//終止時間 html += "<tr>"; html += "<td>" + (i + 1) + "</td>"; html += "<td>" + item.PlaceTest + "</td>"; html += "<td>" + TKTestDate + "</td>"; html += "<td>" + TKBeginTime + "</td>"; html += "<td>" + TKEndTime + "</td>"; html += "<td>" + item.RegNumTotal + "</td>"; html += "<td>" + item.RegNum + "</td>"; html += "<td>" + item.Explain + "</td>"; html += "<td><a href='javascript:void()' onclick='TKBook(\"" + item.TKCode + "\"," + item.Type + ")' >預約</a></td>"; html += "</tr>"; }); //$(".table-list tbody").html(html); $("#select_tableList tbody").html(html); $("#select_tableList tbody tr").click(function () { $(this).toggleClass("curr"); }); //$(".table-list tbody tr").click(function () { $(this).toggleClass("curr"); }); } }) } }); //時間轉換 function getTime(/** timestamp=0 **/) { var ts = arguments[0] || 0; var t, y, m, d, h, i, s; t = ts ? new Date(ts * 1000) : new Date(); y = t.getFullYear(); m = t.getMonth() + 1; d = t.getDate(); h = t.getHours(); i = t.getMinutes(); s = t.getSeconds(); // 可根據需要在這裡定義時間格式 return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + ' ' + (h < 10 ? '0' + h : h) + ':' + (i < 10 ? '0' + i : i) + ':' + (s < 10 ? '0' + s : s); }</span>