回答編集履歴
3
.
answer
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
}
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
入力されたフィールドだけ変更したいなら、`this` を渡しましょう。
|
|
11
|
+
入力されたフィールドだけ変更したいなら、`this` を渡すとか `event.target` を使うなどしましょう。
|
|
12
12
|
```html
|
|
13
13
|
<input class="box" type="text" name="name" oninput="inputChange(this)">
|
|
14
14
|
```
|
2
this
answer
CHANGED
|
@@ -8,11 +8,14 @@
|
|
|
8
8
|
}
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
入力されたフィールドだけ変更したいなら、`this` を
|
|
11
|
+
入力されたフィールドだけ変更したいなら、`this` を渡しましょう。
|
|
12
|
+
```html
|
|
13
|
+
<input class="box" type="text" name="name" oninput="inputChange(this)">
|
|
14
|
+
```
|
|
12
15
|
```js
|
|
13
|
-
function inputChange(){
|
|
16
|
+
function inputChange(input) {
|
|
14
|
-
|
|
17
|
+
input.style.backgroundColor = '#F0E0E0';
|
|
15
|
-
|
|
18
|
+
input.style.color = 'red';
|
|
16
|
-
|
|
19
|
+
input.style.fontWeight = 'bold';
|
|
17
20
|
}
|
|
18
21
|
```
|
1
.
answer
CHANGED
|
@@ -7,3 +7,12 @@
|
|
|
7
7
|
box.style.fontWeight = 'bold';
|
|
8
8
|
}
|
|
9
9
|
```
|
|
10
|
+
|
|
11
|
+
入力されたフィールドだけ変更したいなら、`this` を使いましょう。
|
|
12
|
+
```js
|
|
13
|
+
function inputChange(){
|
|
14
|
+
this.style.backgroundColor = '#F0E0E0';
|
|
15
|
+
this.style.color = 'red';
|
|
16
|
+
this.style.fontWeight = 'bold';
|
|
17
|
+
}
|
|
18
|
+
```
|