回答編集履歴
1
調整
answer
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
for文が好きでない方のために一応別解
|
2
|
+
※IE polyfill追記しました
|
2
3
|
```javascript
|
3
4
|
<script>
|
5
|
+
//IE polyfill
|
6
|
+
if(!Array.prototype.fill){
|
7
|
+
Array.prototype.fill=function(v){
|
8
|
+
for(var i=0;i<this.length;i++) this[i]=v;
|
9
|
+
return this;
|
10
|
+
}
|
11
|
+
}
|
4
12
|
window.addEventListener('DOMContentLoaded', function(e){
|
5
13
|
Array(2).fill(null).forEach(function(i,j){
|
6
14
|
document.querySelector('#hoge'+j).addEventListener('click', function(e) {
|