Hi dear welcome to Ascode Blog . In this post we are going to learn How to use If/Else Contion In Javascript. First Creat A index.html file Copy This HTML CODE and pest it one your code editor. 2ndly creat style.css file Then Copy The CSS CODE . 3ndly creat ap.js file Then Copy The Javascript CODEand pest it then open the index.html file with your browser.
HTML
<!DOCTYPE html>
<html lang="en">
<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>If Else Uses javascript</title>
</head>
<body>
<div id="number"></div>
</body>
</html>
CSS
*{
margin: 0;
padding: 0;
font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center ;
min-height: 100vh;
}
#number {
font-size: 7rem;
padding: 30px 50px;
background: #000;
color: #fff;
width: fit-content;
font-weight: 600;
border-radius:10px ;
}
Javascript
let number = document.getElementById('number');
let Counter = 0;
setInterval(() => {
if(Counter == 100){
clearInterval();
}
else{
Counter += 1;
number.innerHTML = Counter + '';
}
}, 100);
0 Comments