함수
: 코드의 유지보수 / 길이 / 가독성 측면에서의 장점들
<script>
function nightDayHandler(self){
var target=document.querySelector('body');
if(self.value==='night'){
target.style.backgroundColor='black';
target.style.color='white';
self.value='day'
}
else{
target.style.backgroundColor='white';
target.style.color='black';
self.value='night'
}
}
</script>
<input type="button" value="night" onclick="nightDayHandler(this);">
'Web > HTML+CSS+JS' 카테고리의 다른 글
[스파르타 코딩클럽] 크리스마스 디데이 캘린더 만들기 (0) | 2023.12.24 |
---|---|
웹프로그래밍첫걸음 7~10장. CSS, JavaScript (1) | 2023.06.14 |
웹프로그래밍첫걸음 5장. 폼 활용하기 (0) | 2023.05.01 |
웹프로그래밍첫걸음 4장. 링크와 멀티미디어 표현하기 (0) | 2023.05.01 |
웹프로그래밍첫걸음 3장. 문서 구조 표현하기 (0) | 2023.05.01 |