Skip to content

Instantly share code, notes, and snippets.

@egoing
Created April 10, 2022 12:42
Show Gist options
  • Save egoing/4145b3a47ddfb12ea2c7016b0c67df39 to your computer and use it in GitHub Desktop.
Save egoing/4145b3a47ddfb12ea2c7016b0c67df39 to your computer and use it in GitHub Desktop.
자바스크립트 예제 - 일기예보
<html>
<body>
<div id="temperature">
<div>기온</div>
<ol>
<li id="element-0" style="display:block;">서울 1°C</li>
<li id="element-1">청주 2°C</li>
<li id="element-2">성주 3°C</li>
</ol>
</div>
<style>
div>*{
border:5px solid black;
padding:0;
margin:0;
box-sizing:content-box;
padding:5px;
}
div>*:first-child{
border-right:0;
background-color:black;
color:white;
}
#temperature {
display:grid;
grid-template-columns: 100px 150px;
}
#temperature ol li {
display:none;
}
</style>
<script>
let i = 0;
setInterval(function(){
console.log(i);
i = (i + 1)%3;
let lis = document.querySelectorAll('ol li');
for(let i=0; i<lis.length; i++){
lis[i].style.display = 'none';
}
document.querySelector('#element-'+i).style.display = 'block';
}, 1000);
</script>
</body>
</html>
@egoing
Copy link
Author

egoing commented Apr 10, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment