回答編集履歴
1
追記
test
CHANGED
@@ -55,3 +55,107 @@
|
|
55
55
|
<div class="change blue">色よ変われ!</div>
|
56
56
|
|
57
57
|
```
|
58
|
+
|
59
|
+
# 追記
|
60
|
+
|
61
|
+
.kokomo:beforeの色を変える
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
```css
|
66
|
+
|
67
|
+
.red{ background-Color: red;}
|
68
|
+
|
69
|
+
.blue{ background-Color: blue;}
|
70
|
+
|
71
|
+
.green{ background-Color:green;}
|
72
|
+
|
73
|
+
.beforered:before{background-Color: red;}
|
74
|
+
|
75
|
+
.beforeblue:before{ background-Color: blue;}
|
76
|
+
|
77
|
+
.beforegreen:before{ background-Color:green;}
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
.box {margin: 20px;}
|
82
|
+
|
83
|
+
.change {
|
84
|
+
|
85
|
+
color: #fff;
|
86
|
+
|
87
|
+
font-weight: bold;
|
88
|
+
|
89
|
+
width: 200px;
|
90
|
+
|
91
|
+
margin: 20px;
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
.kokomo {
|
96
|
+
|
97
|
+
color: #000000;
|
98
|
+
|
99
|
+
margin: 20px;
|
100
|
+
|
101
|
+
font-weight: bold;
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
.kokomo:before {
|
106
|
+
|
107
|
+
content: '';
|
108
|
+
|
109
|
+
position: absolute;
|
110
|
+
|
111
|
+
top: 0;
|
112
|
+
|
113
|
+
width: 20px;
|
114
|
+
|
115
|
+
height: 20px;
|
116
|
+
|
117
|
+
border-radius: 50%;
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
```javascript
|
124
|
+
|
125
|
+
$(function(){
|
126
|
+
|
127
|
+
$('select').on('change',function(){
|
128
|
+
|
129
|
+
$('.change').removeClass('red blue green').addClass($(this).val());
|
130
|
+
|
131
|
+
$('.kokomo').removeClass('beforered beforeblue beforegreen').addClass("before"+$(this).val());
|
132
|
+
|
133
|
+
});
|
134
|
+
|
135
|
+
});
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
```HTML
|
140
|
+
|
141
|
+
<div class="box">
|
142
|
+
|
143
|
+
<select class="select_color" name="onamae" data-required="no" data-type="select">
|
144
|
+
|
145
|
+
<option value="blue">ブルー</option>
|
146
|
+
|
147
|
+
<option value="red">レッド</option>
|
148
|
+
|
149
|
+
<option value="green">グリーン</option>
|
150
|
+
|
151
|
+
</select>
|
152
|
+
|
153
|
+
</div>
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
<div class="change blue">ここの色が変わる!</div>
|
158
|
+
|
159
|
+
<div class="kokomo beforeblue">ここも</div>
|
160
|
+
|
161
|
+
```
|