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

回答編集履歴

3

.

2023/10/27 08:08

投稿

int32_t
int32_t

スコア22019

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

2023/10/27 08:05

投稿

int32_t
int32_t

スコア22019

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
- this.style.backgroundColor = '#F0E0E0';
17
+ input.style.backgroundColor = '#F0E0E0';
15
- this.style.color = 'red';
18
+ input.style.color = 'red';
16
- this.style.fontWeight = 'bold';
19
+ input.style.fontWeight = 'bold';
17
20
  }
18
21
  ```

1

.

2023/10/27 08:02

投稿

int32_t
int32_t

スコア22019

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
+ ```