回答編集履歴

1

調整

2019/01/30 05:18

投稿

yambejp
yambejp

スコア114839

test CHANGED
@@ -32,13 +32,19 @@
32
32
 
33
33
  {"company_name":"H社","item_name":"100点"},
34
34
 
35
- {"company_name":"H社","item_name":"100点"},
36
-
37
35
  ];
38
36
 
39
37
  var lastpage=parseInt((results.length-1)/viewperpage);
40
38
 
41
39
  $('#current').val(currentpage+1).on('change',function(){
40
+
41
+ currentpage=(parseInt($('#current').val())||1)-1;
42
+
43
+ if(currentpage<0) currentpage=0;
44
+
45
+ if(currentpage>lastpage) currentpage=lastpage;
46
+
47
+ $('#current').val(currentpage+1);
42
48
 
43
49
  var offset=currentpage<lastpage?0:(viewperpage*(lastpage+1)-results.length);
44
50
 
@@ -70,19 +76,13 @@
70
76
 
71
77
  $('#prev').on('click',function(){
72
78
 
73
- if(currentpage>0) currentpage--;
74
-
75
- $('#current').val(currentpage+1).trigger('change');
79
+ if(currentpage>0) $('#current').val(currentpage).trigger('change');
76
80
 
77
81
  });
78
82
 
79
83
  $('#next').on('click',function(){
80
84
 
81
- console.log([currentpage,lastpage])
82
-
83
- if(currentpage<lastpage) currentpage++;
84
-
85
- $('#current').val(currentpage+1).trigger('change');
85
+ if(currentpage<lastpage) $('#current').val(currentpage+2).trigger('change');
86
86
 
87
87
  });
88
88