<title>Document</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@200;400;600;800&display=swap" rel="stylesheet" />
<style>
* {
margin: 0;
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
}
.container {
background-color: lightsalmon;
margin: 20px auto;
margin-top: 20px auto;
border: solid 2px forestgreen;
max-width: 333px;
text-align: center;
border-radius: 5px;
padding: 10px;
}
.container p {
border: solid 2px;
padding: 5px;
max-width: 100px;
margin: 10px auto;
padding: 5px;
background-color: lime;
}
.container h1 {
margin-top: 0px;
}
.btn {
padding: 2px;
border: solid 1px black;
color: rgb(82, 120, 182);
background-color: rgb(0, 0, 0);
border-radius: 8px;
margin: 10px;
padding: 5px;
}
.tablets {
display: flex;
padding: 0 5px;
}
#circleLab {
max-width: 200px;
height: 700px;
border: solid 1px;
margin: auto;
}
</style>
</head>
<body>
<div class="container">
<h1>Секундомер</h1>
<p id="time">0</p>
<div id="tablets">
<button id="start" class="btn">Старт</button>
<button id="stop" class="btn">Стоп</button>
<button id="reset" class="btn">Сброс</button>
<button id="circle" class="btn">Круг</button>
</div>
<div id="circleLab">
</div>
</div>
<script>
const time = document.querySelector("#time");
const start = document.querySelector("#start");
const stop = document.querySelector("#stop");
const reset = document.querySelector("#reset");
const circle = document.querySelector("#circle");
let circleS = document.querySelector("#circleLab");
let currentTime = 0;
time.innerHTML = currentTime;
let intervalId;
start.addEventListener("click", () => {
intervalId = setInterval(() => {
currentTime += 0.01;
time.innerHTML = currentTime.toFixed(2);
}, 10);
});
stop.addEventListener("click", () => {
clearInterval(intervalId);
if (currentTime === 0) {
start.innerText = "Старт";
} else {
start.innerHTML = "Продолжить"
}
});
circle.addEventListener("click", () => {
let newCircle = document.createElement('p');
newCircle.innerHTML = currentTime.toFixed(4);
circleS.append(newCircle)
});
reset.addEventListener("click", () => {
clearInterval(intervalId);
currentTime = 0;
time.innerHTML = 0;
start.innerHTML = "Старт"
p = Array.
});
</script>
</body>
</html>
Может бан?
что за песочница?
Что такое p = Array. ?
Массив, ахаха
Обсуждают сегодня