質問編集履歴
2
補足
test
CHANGED
File without changes
|
test
CHANGED
@@ -120,11 +120,11 @@
|
|
120
120
|
|
121
121
|
}
|
122
122
|
|
123
|
-
|
123
|
+
```
|
124
|
-
|
125
|
-
|
126
|
-
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
-
javascri
|
127
|
+
javascript全文
|
128
128
|
|
129
129
|
```JavaScript
|
130
130
|
|
1
題名変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
for in文の中で変数を使いたい
|
1
|
+
for in文の条件式中で変数を使いたい
|
test
CHANGED
@@ -68,13 +68,115 @@
|
|
68
68
|
|
69
69
|
}
|
70
70
|
|
71
|
+
```
|
72
|
+
|
73
|
+
やりたい感じ
|
74
|
+
|
75
|
+
```JavaScript
|
76
|
+
|
77
|
+
var styleA = {
|
78
|
+
|
79
|
+
width: "10%",
|
80
|
+
|
81
|
+
height: "10%",
|
82
|
+
|
83
|
+
backgroundColor: "green"
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
var styleB = {
|
90
|
+
|
91
|
+
width: "15%",
|
92
|
+
|
93
|
+
height: "15%",
|
94
|
+
|
95
|
+
backgroundColor: "yellow"
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
//障害物作成
|
102
|
+
|
103
|
+
function Makeobject(){
|
104
|
+
|
105
|
+
var object = document.createElement("div");
|
106
|
+
|
107
|
+
topzone.appendChild(object);
|
108
|
+
|
109
|
+
console.log(object);
|
110
|
+
|
111
|
+
var i = "styleA";
|
112
|
+
|
113
|
+
console.log(styleB);
|
114
|
+
|
115
|
+
for(styleNumber in i){
|
116
|
+
|
117
|
+
var objectAstyle = object.style;
|
118
|
+
|
119
|
+
objectAstyle[styleNumber] = styleA[styleNumber];
|
120
|
+
|
121
|
+
}
|
122
|
+
|
71
123
|
```
|
72
124
|
|
125
|
+
|
126
|
+
|
73
|
-
|
127
|
+
javascriot全文
|
74
128
|
|
75
129
|
```JavaScript
|
76
130
|
|
131
|
+
document.addEventListener("DOMContentLoaded", function() {
|
132
|
+
|
133
|
+
//初期設定~
|
134
|
+
|
135
|
+
(function () {
|
136
|
+
|
137
|
+
var button = document.getElementById("button"),
|
138
|
+
|
139
|
+
container = document.getElementById("container"),
|
140
|
+
|
141
|
+
topzone = document.getElementById("topzone"),
|
142
|
+
|
143
|
+
bottomzone = document.getElementById("bottomzone"),
|
144
|
+
|
145
|
+
escaper = document.getElementById("escaper");
|
146
|
+
|
147
|
+
console.log(button);
|
148
|
+
|
149
|
+
//~初期設定
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
//開始処理
|
154
|
+
|
155
|
+
button.addEventListener("click",Startgame,false);
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
function Startgame(){
|
160
|
+
|
161
|
+
alert("game started!!");
|
162
|
+
|
163
|
+
//障害物作成
|
164
|
+
|
165
|
+
setInterval(Makeobject,1000);
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
//クリック動作
|
170
|
+
|
171
|
+
container.addEventListener("click",Moveescaper,false);
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
}());
|
176
|
+
|
177
|
+
|
178
|
+
|
77
|
-
var styleA = {
|
179
|
+
var styleA = {
|
78
180
|
|
79
181
|
width: "10%",
|
80
182
|
|
@@ -120,108 +222,6 @@
|
|
120
222
|
|
121
223
|
}
|
122
224
|
|
123
|
-
```
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
javascriot全文
|
128
|
-
|
129
|
-
```JavaScript
|
130
|
-
|
131
|
-
document.addEventListener("DOMContentLoaded", function() {
|
132
|
-
|
133
|
-
//初期設定~
|
134
|
-
|
135
|
-
(function () {
|
136
|
-
|
137
|
-
var button = document.getElementById("button"),
|
138
|
-
|
139
|
-
container = document.getElementById("container"),
|
140
|
-
|
141
|
-
topzone = document.getElementById("topzone"),
|
142
|
-
|
143
|
-
bottomzone = document.getElementById("bottomzone"),
|
144
|
-
|
145
|
-
escaper = document.getElementById("escaper");
|
146
|
-
|
147
|
-
console.log(button);
|
148
|
-
|
149
|
-
//~初期設定
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
//開始処理
|
154
|
-
|
155
|
-
button.addEventListener("click",Startgame,false);
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
function Startgame(){
|
160
|
-
|
161
|
-
alert("game started!!");
|
162
|
-
|
163
|
-
//障害物作成
|
164
|
-
|
165
|
-
setInterval(Makeobject,1000);
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
//クリック動作
|
170
|
-
|
171
|
-
container.addEventListener("click",Moveescaper,false);
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
}());
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
var styleA = {
|
180
|
-
|
181
|
-
width: "10%",
|
182
|
-
|
183
|
-
height: "10%",
|
184
|
-
|
185
|
-
backgroundColor: "green"
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
var styleB = {
|
192
|
-
|
193
|
-
width: "15%",
|
194
|
-
|
195
|
-
height: "15%",
|
196
|
-
|
197
|
-
backgroundColor: "yellow"
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
//障害物作成
|
204
|
-
|
205
|
-
function Makeobject(){
|
206
|
-
|
207
|
-
var object = document.createElement("div");
|
208
|
-
|
209
|
-
topzone.appendChild(object);
|
210
|
-
|
211
|
-
console.log(object);
|
212
|
-
|
213
|
-
var i = "styleA";
|
214
|
-
|
215
|
-
console.log(styleB);
|
216
|
-
|
217
|
-
for(styleNumber in i){
|
218
|
-
|
219
|
-
var objectAstyle = object.style;
|
220
|
-
|
221
|
-
objectAstyle[styleNumber] = styleA[styleNumber];
|
222
|
-
|
223
|
-
}
|
224
|
-
|
225
225
|
|
226
226
|
|
227
227
|
//障害物落下
|