回答編集履歴
1
追記
test
CHANGED
@@ -25,3 +25,59 @@
|
|
25
25
|
<input type="text" name="txt_country_name" size="30" maxlength="100" value="">
|
26
26
|
|
27
27
|
```
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
# 追記
|
32
|
+
|
33
|
+
こういうこと?
|
34
|
+
|
35
|
+
```javascript
|
36
|
+
|
37
|
+
HTMLElement.prototype.trigger=function(eventStr){
|
38
|
+
|
39
|
+
if (document.createEvent) {
|
40
|
+
|
41
|
+
var e = document.createEvent("HTMLEvents");
|
42
|
+
|
43
|
+
e.initEvent(eventStr, true, true );
|
44
|
+
|
45
|
+
return this.dispatchEvent(e);
|
46
|
+
|
47
|
+
} else {
|
48
|
+
|
49
|
+
var e = document.createEventObject();
|
50
|
+
|
51
|
+
return this.fireEvent("on"+eventStr, e);
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
};
|
56
|
+
|
57
|
+
window.addEventListener('DOMContentLoaded', function(e){
|
58
|
+
|
59
|
+
[].forEach.call(document.querySelectorAll('input[name="country_kbn"]'),function(x){
|
60
|
+
|
61
|
+
x.addEventListener('change',function(e){
|
62
|
+
|
63
|
+
document.querySelector('input[name="txt_country_name"]').style.display=(e.target.value==1?'none':'inline-block');
|
64
|
+
|
65
|
+
});
|
66
|
+
|
67
|
+
if(x.checked) x.trigger('change');
|
68
|
+
|
69
|
+
});
|
70
|
+
|
71
|
+
});
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
```HTML
|
76
|
+
|
77
|
+
<input type="radio" id="country_kbn1" name="country_kbn" value="1" checked> 日本
|
78
|
+
|
79
|
+
<input type="radio" id="country_kbn2" name="country_kbn" value="2"> 海外
|
80
|
+
|
81
|
+
<input type="text" name="txt_country_name" size="30" maxlength="100" value="">
|
82
|
+
|
83
|
+
```
|