teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

4

変更

2020/02/26 00:18

投稿

NEO_PLANETT-777
NEO_PLANETT-777

スコア333

answer CHANGED
@@ -3,15 +3,16 @@
3
3
  ```jQuery
4
4
  <script>
5
5
  $(function() {
6
+ var tmp = parseInt($(this).text());
6
7
  $('.box').on('click',function() {
7
- if ( parseInt($(this).text()) < 上限値 ) {
8
+ if ( tmp < 上限値 ) {
8
- $(this).text(parseInt($(this).text()) + 1);
9
+ $(this).text(tmp + 1);
9
10
  }
10
11
  });
11
12
 
12
13
  $('.box').on('contextmenu',function(){
13
- if ( parseInt($(this).text()) > 下限値 ) {
14
+ if ( tmp > 下限値 ) {
14
- $(this).text(parseInt($(this).text()) - 1);
15
+ $(this).text(tmp - 1);
15
16
  }
16
17
  });
17
18
  });

3

訂正

2020/02/26 00:18

投稿

NEO_PLANETT-777
NEO_PLANETT-777

スコア333

answer CHANGED
@@ -4,14 +4,14 @@
4
4
  <script>
5
5
  $(function() {
6
6
  $('.box').on('click',function() {
7
- if ( parseInt($(this).text()) > 限値 ) {
7
+ if ( parseInt($(this).text()) < 限値 ) {
8
- $(this).text(parseInt($(this).text()) - 1);
8
+ $(this).text(parseInt($(this).text()) + 1);
9
9
  }
10
10
  });
11
11
 
12
12
  $('.box').on('contextmenu',function(){
13
- if ( parseInt($(this).text()) < 限値 ) {
13
+ if ( parseInt($(this).text()) > 限値 ) {
14
- $(this).text(parseInt($(this).text()) + 1);
14
+ $(this).text(parseInt($(this).text()) - 1);
15
15
  }
16
16
  });
17
17
  });

2

訂正

2020/02/26 00:15

投稿

NEO_PLANETT-777
NEO_PLANETT-777

スコア333

answer CHANGED
@@ -5,13 +5,13 @@
5
5
  $(function() {
6
6
  $('.box').on('click',function() {
7
7
  if ( parseInt($(this).text()) > 下限値 ) {
8
- $(this).text(parseInt($(this).text()) + 1);
8
+ $(this).text(parseInt($(this).text()) - 1);
9
9
  }
10
10
  });
11
11
 
12
12
  $('.box').on('contextmenu',function(){
13
13
  if ( parseInt($(this).text()) < 上限値 ) {
14
- $(this).text(parseInt($(this).text()) - 1);
14
+ $(this).text(parseInt($(this).text()) + 1);
15
15
  }
16
16
  });
17
17
  });

1

誤記訂正

2020/02/26 00:13

投稿

NEO_PLANETT-777
NEO_PLANETT-777

スコア333

answer CHANGED
@@ -4,13 +4,13 @@
4
4
  <script>
5
5
  $(function() {
6
6
  $('.box').on('click',function() {
7
- if ( $(this).text() > 下限値 ) {
7
+ if ( parseInt($(this).text()) > 下限値 ) {
8
8
  $(this).text(parseInt($(this).text()) + 1);
9
9
  }
10
10
  });
11
11
 
12
12
  $('.box').on('contextmenu',function(){
13
- if ( $(this).text() < 上限値 ) {
13
+ if ( parseInt($(this).text()) < 上限値 ) {
14
14
  $(this).text(parseInt($(this).text()) - 1);
15
15
  }
16
16
  });