回答編集履歴
2
修正
test
CHANGED
@@ -48,7 +48,7 @@
|
|
48
48
|
|
49
49
|
input.kiiro{background-Color:yellow;}
|
50
50
|
|
51
|
-
input[n
|
51
|
+
input[readonly]{background-Color:gray;}
|
52
52
|
|
53
53
|
```
|
54
54
|
|
1
sample
test
CHANGED
@@ -1 +1,71 @@
|
|
1
1
|
テキストボックスにはoninput、ラジオボタンにはonchangeを利用して下さい
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
# sample
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
```javascript
|
10
|
+
|
11
|
+
window.onload=function(){
|
12
|
+
|
13
|
+
document.querySelector('input[name=nyuryoku]').addEventListener('input',function(e){
|
14
|
+
|
15
|
+
document.querySelector('input[name=hyouji]').value=e.target.value;
|
16
|
+
|
17
|
+
});
|
18
|
+
|
19
|
+
document.addEventListener('change',function(e){
|
20
|
+
|
21
|
+
var t=e.target;
|
22
|
+
|
23
|
+
if(t.nodeName=="INPUT" && t.name=="color"){
|
24
|
+
|
25
|
+
var v=document.querySelector('input[name=color]:checked').value;
|
26
|
+
|
27
|
+
with(document.querySelector('input[name=nyuryoku]').classList){
|
28
|
+
|
29
|
+
remove('aka','kiiro');
|
30
|
+
|
31
|
+
if(v=="aka") add('aka');
|
32
|
+
|
33
|
+
if(v=="kiiro") add('kiiro');
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
});
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
```
|
44
|
+
|
45
|
+
```css
|
46
|
+
|
47
|
+
input.aka{background-Color:red;}
|
48
|
+
|
49
|
+
input.kiiro{background-Color:yellow;}
|
50
|
+
|
51
|
+
input[name=hyouji]{background-Color:gray;}
|
52
|
+
|
53
|
+
```
|
54
|
+
|
55
|
+
```HTML
|
56
|
+
|
57
|
+
<form>
|
58
|
+
|
59
|
+
入力:<input type="text" name="nyuryoku"><br>
|
60
|
+
|
61
|
+
表示:<input type="text" name="hyouji" readonly><br>
|
62
|
+
|
63
|
+
<input type="radio" name="color" value="mushoku">無色
|
64
|
+
|
65
|
+
<input type="radio" name="color" value="aka">赤
|
66
|
+
|
67
|
+
<input type="radio" name="color" value="kiiro">黄色
|
68
|
+
|
69
|
+
</form>
|
70
|
+
|
71
|
+
```
|