아~주 심플한 SPA만들기
<body>
<h1><a href="index.html">WEB</a></h1>
<input id="night_day" type="button" value="night" onclick="
nightDayHandler(this);
">
<li>
<a onclick="getText('html')">HTML</a>
</li>
<li>
<a onclick="getText('css')">css</a>
</li>
<li>
<a onclick="getText('JavaScript')">JavaScript</a>
</li>
</ol>
<article>
</article>
<script>
function getText(page){
fetch(page).then(function(response) {
response.text().then(function(text) {
document.querySelector('article').innerHTML = text
})
})
}
</script>
</body>
결과