回答編集履歴
3
修正
test
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
|
65
65
|
$("#value").html(plan[plan_id]);
|
66
66
|
|
67
|
-
$(next_option1[plan_id]).css('display','block');
|
67
|
+
$(next_option1[plan_id]).css('display','inline-block');
|
68
68
|
|
69
69
|
$(".plans").css('display','none');
|
70
70
|
|
@@ -102,7 +102,7 @@
|
|
102
102
|
|
103
103
|
$("#value").html(value);
|
104
104
|
|
105
|
-
$(".options
|
105
|
+
$(".options2").css('display','none');
|
106
106
|
|
107
107
|
});
|
108
108
|
|
2
追記
test
CHANGED
@@ -5,6 +5,12 @@
|
|
5
5
|
HTMLとJavaScriptの技術さえあれば同等のものは作れるかと。
|
6
6
|
|
7
7
|
|
8
|
+
|
9
|
+
###追記
|
10
|
+
|
11
|
+
デザイン性もへったくれもないコードです。
|
12
|
+
|
13
|
+
もっと短く簡単にできると思うので頑張ってください。
|
8
14
|
|
9
15
|
```HTML
|
10
16
|
|
@@ -46,7 +52,7 @@
|
|
46
52
|
|
47
53
|
```
|
48
54
|
|
49
|
-
```
|
55
|
+
```jQuery
|
50
56
|
|
51
57
|
$('.plan').on('click', function() {
|
52
58
|
|
1
\
test
CHANGED
@@ -3,3 +3,105 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
HTMLとJavaScriptの技術さえあれば同等のものは作れるかと。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
```HTML
|
10
|
+
|
11
|
+
<div class=plans>
|
12
|
+
|
13
|
+
<div class=plan id=plan1>Plan1 (10000yen)</div>
|
14
|
+
|
15
|
+
<div class=plan id=plan2>Plan2 (20000yen)</div>
|
16
|
+
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class=options1>
|
20
|
+
|
21
|
+
<div class=option1 id=option1_1>Option1 (50000yen)</div>
|
22
|
+
|
23
|
+
<div class=option1 id=option1_2>Option2 (10000yen)</div>
|
24
|
+
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div class=options2>
|
28
|
+
|
29
|
+
<div class=option2 id=option2_1>Option1 (1100yen)</div>
|
30
|
+
|
31
|
+
<div class=option2 id=option2_2>Option2 (500yen)</div>
|
32
|
+
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id=value></div>
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
```CSS
|
40
|
+
|
41
|
+
.options1, .options2 {
|
42
|
+
|
43
|
+
display: none;
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
```JS
|
50
|
+
|
51
|
+
$('.plan').on('click', function() {
|
52
|
+
|
53
|
+
var plan_id = $(this).attr('id');
|
54
|
+
|
55
|
+
var plan = {plan1:10000, plan2:20000};
|
56
|
+
|
57
|
+
var next_option1 = {plan1:".options1", plan2:".options2"};
|
58
|
+
|
59
|
+
$("#value").html(plan[plan_id]);
|
60
|
+
|
61
|
+
$(next_option1[plan_id]).css('display','block');
|
62
|
+
|
63
|
+
$(".plans").css('display','none');
|
64
|
+
|
65
|
+
});
|
66
|
+
|
67
|
+
$('.option1').on('click', function() {
|
68
|
+
|
69
|
+
var option1_id = $(this).attr('id');
|
70
|
+
|
71
|
+
options1 = {option1_1:50000, option1_2:10000};
|
72
|
+
|
73
|
+
var value1 = $("#value").html();
|
74
|
+
|
75
|
+
var value2 = options1[option1_id];
|
76
|
+
|
77
|
+
var value = parseInt(value1) + parseInt(value2);
|
78
|
+
|
79
|
+
$("#value").html(value);
|
80
|
+
|
81
|
+
$(".options1").css('display','none');
|
82
|
+
|
83
|
+
});
|
84
|
+
|
85
|
+
$('.option2').on('click', function() {
|
86
|
+
|
87
|
+
var option2_id = $(this).attr('id');
|
88
|
+
|
89
|
+
options1 = {option2_1:1100, option2_2:500};
|
90
|
+
|
91
|
+
var value1 = $("#value").html();
|
92
|
+
|
93
|
+
var value2 = options1[option2_id];
|
94
|
+
|
95
|
+
var value = parseInt(value1) + parseInt(value2);
|
96
|
+
|
97
|
+
$("#value").html(value);
|
98
|
+
|
99
|
+
$(".options1").css('display','none');
|
100
|
+
|
101
|
+
});
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
[CodePen](https://codepen.io/asuchi0819/pen/pozLPoz)
|