回答編集履歴
3
参考
test
CHANGED
@@ -5,3 +5,17 @@
|
|
5
5
|
jQueryでしたら、afterとかbeforeとか.html()とかが良いかもしれません
|
6
6
|
|
7
7
|
※非同期でうけとったhtmlをどこに放り込みたいかによります
|
8
|
+
|
9
|
+
# 参考
|
10
|
+
```javascript
|
11
|
+
<script>
|
12
|
+
window.addEventListener('DOMContentLoaded', async()=>{
|
13
|
+
const footer=document.querySelector('footer');
|
14
|
+
const html=await fetch('diary.html').then(res=>res.text());
|
15
|
+
footer.insertAdjacentHTML('beforeend',html);
|
16
|
+
});
|
17
|
+
</script>
|
18
|
+
<header>header</header>
|
19
|
+
<main>main</main>
|
20
|
+
<footer>footer</footer>
|
21
|
+
```
|
2
ほそく
test
CHANGED
@@ -2,4 +2,6 @@
|
|
2
2
|
|
3
3
|
- [element.insertAdjacentHTML - Web API | MDN](https://developer.mozilla.org/ja/docs/Web/API/Element/insertAdjacentHTML)
|
4
4
|
|
5
|
+
jQueryでしたら、afterとかbeforeとか.html()とかが良いかもしれません
|
6
|
+
|
5
7
|
※非同期でうけとったhtmlをどこに放り込みたいかによります
|
1
調整
test
CHANGED
@@ -1,3 +1,5 @@
|
|
1
1
|
document.writeではなくinsertAdjacentHTMLなどご利用ください
|
2
2
|
|
3
3
|
- [element.insertAdjacentHTML - Web API | MDN](https://developer.mozilla.org/ja/docs/Web/API/Element/insertAdjacentHTML)
|
4
|
+
|
5
|
+
※非同期でうけとったhtmlをどこに放り込みたいかによります
|