Created
April 10, 2022 12:42
-
-
Save egoing/4145b3a47ddfb12ea2c7016b0c67df39 to your computer and use it in GitHub Desktop.
자바스크립트 예제 - 일기예보
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
라이브 예제 : https://jsbin.com/dayiquzefo/edit?html,output