回答編集履歴
1
念の為
test
CHANGED
@@ -49,3 +49,43 @@
|
|
49
49
|
<a href="#" class="target">click here!</a>
|
50
50
|
|
51
51
|
```
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
# 修正版
|
56
|
+
|
57
|
+
念の為修正版挙げておきます
|
58
|
+
|
59
|
+
```javascript
|
60
|
+
|
61
|
+
<script>
|
62
|
+
|
63
|
+
window.addEventListener('DOMContentLoaded', function(e){
|
64
|
+
|
65
|
+
[].forEach.call(document.querySelectorAll(".target"),function(x){
|
66
|
+
|
67
|
+
x.addEventListener('click',function(e){
|
68
|
+
|
69
|
+
e.preventDefault();
|
70
|
+
|
71
|
+
var UserInput=prompt("input");
|
72
|
+
|
73
|
+
location.href="http://exsample.com/"+UserInput+e.target.getAttribute("id")+".html";
|
74
|
+
|
75
|
+
});
|
76
|
+
|
77
|
+
});
|
78
|
+
|
79
|
+
});
|
80
|
+
|
81
|
+
</script>
|
82
|
+
|
83
|
+
<a href="#" id="01" class="target">01</a>
|
84
|
+
|
85
|
+
<a href="#" id="02" class="target">02</a>
|
86
|
+
|
87
|
+
<a href="#" id="03" class="target">03</a>
|
88
|
+
|
89
|
+
<a href="http://exsample.com/">non target</a>
|
90
|
+
|
91
|
+
```
|