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

回答編集履歴

2

間違った

2016/03/12 09:54

投稿

shi_ue
shi_ue

スコア4437

answer CHANGED
@@ -1,7 +1,7 @@
1
1
  どんぴしゃな回答がamaranthineさんから出ているのでjqueryを使わない方法で。
2
2
  ```HTML
3
3
  <script type="text/javascript">
4
- document.onload = function() {
4
+ window.onload = function() {
5
5
  var ar = Array.prototype.slice.call(document.getElementsByTagName('input'));
6
6
  for(e in ar) {
7
7
  ar[e].onchange = function() {

1

ソースの変更

2016/03/12 09:54

投稿

shi_ue
shi_ue

スコア4437

answer CHANGED
@@ -1,14 +1,16 @@
1
1
  どんぴしゃな回答がamaranthineさんから出ているのでjqueryを使わない方法で。
2
- ```Javascript
2
+ ```HTML
3
3
  <script type="text/javascript">
4
+ document.onload = function() {
4
- var ar = Array.prototype.slice.call(document.getElementsByTagName('input'));
5
+ var ar = Array.prototype.slice.call(document.getElementsByTagName('input'));
5
- for(e in ar) {
6
+ for(e in ar) {
6
- ar[e].onchange = function() {
7
+ ar[e].onchange = function() {
7
- for(ee in ar) {
8
+ for(ee in ar) {
8
- ar[ee].checked = false;
9
+ ar[ee].checked = false;
9
- }
10
+ }
10
- this.checked = true;
11
+ this.checked = true;
11
- };
12
+ };
12
- }
13
+ }
14
+ };
13
15
  </script>
14
16
  ```