250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- button
- keyframes
- SWIFT
- jQuery
- image
- MAC
- iPhone
- 풀스택
- html5
- HTML
- Animation
- CSS
- effect
- css3
- 프론트엔드
- 자바스크립트
- javascript
- 비전공자
- hover
- 개발자
- php
- 비전공 개발자
- IOS
- react
- xcode
- ipad
- iOS 개발자
- front-end
- 백엔드
- 애니메이션
Archives
- Today
- Total
비전공자 개발일기
Counter APP 본문
728x90
SMALL
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>COUNTER APP</title>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
</head>
<body>
<h1>Counter APP</h1>
<p class="counter-preview">0</p>
<div class="buttons" id="allBtns">
<button class="decrement" id="decrement">decrement</button>
<button class="reset" id="reset">reset</button>
<button class="increment" id="increment">increment</button>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-size: 16px;
color: #333;
width: 400px;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
min-height: 100vh;
background-color: #ABDCF0;
}
h1 {
text-transform: uppercase;
}
.counter-preview {
font-size: 8rem;
font-weight: 700;
color: #333;
}
button {
color: #FFF;
border: none;
padding: 10px 20px;
border-radius: 5px;
font-size: 18px;
cursor: pointer;
margin-top: 20px;
margin-left: 1rem;
}
.decrement {
background-color: #4CAF50;
}
.reset {
background-color: #F44336;
}
.increment {
background-color: #2196F3;
}
const display = document.querySelector(".counter-preview");
const allBtns = document.querySelector("#allBtns");
allBtns.addEventListener("click", counter);
let value = 0;
function counter(e) {
const btn = e.target.id;
if (btn === "increment") {
value += 1;
} else if (btn === "decrement") {
value -= 1;
} else {
value = 0;
}
display.textContent = value;
}
728x90
LIST
'Javascript' 카테고리의 다른 글
Glitchy Loading Indicator (0) | 2023.02.26 |
---|---|
To Do List (0) | 2023.02.25 |
Music Player Widget (0) | 2023.02.03 |
Nested Border Radius (0) | 2023.01.21 |
Budget App (0) | 2023.01.18 |