setTimeout() Method in JavaScript | #45

preview_player
Показать описание
setTimeout() Method in JavaScript | #45

Courses:

HTML:

CSS:

Other videos

► How to Make Animated Portfolio Website Using HTML CSS & JS - Light & Dark Mode Website Tutorial:

► Responsive Personal Portfolio Website using HTML & CSS - How to Make a Website:

► Animated Portfolio Website Template in HTML CSS | Animated Personal Website - Responsive Design:

► How To Make A Website Using HTML CSS Bootstrap - Real Estate Website - Bootstrap Website Design:

► Responsive Ecommerce Website:

►CSS Button Hover Effect:

►CSS Loading Animation:

►Video Background Landing Page:

►Working JavaScript Clock:

►CSS Loading Animation Effects:

Instagram:
Рекомендации по теме
Комментарии
Автор

//setTimeout() is a JavaScript function that allows you to schedule the execution of a piece of code after a specified time delay.

//1 second = 1000 milliseconds.

//Example1
console.log('Start');
function hello() {
console.log('Hello world');
}

setTimeout(hello, 3000);
console.log('End');


//Example2
function myFunction() {
let intervalID = setTimeout(alertFunction, 3000);
clearTimeout(intervalID);
console.log(intervalID);
}

function alertFunction() {
alert("Happy Birthday!");
}


//Example3
let counter = 0;
let timeout;
let timer_on = 0;

function timedCount() {
= counter;
counter++;
timeout = setTimeout(timedCount, 1000);
}

function startCount() {
if (!timer_on) {
timer_on = 1;
timedCount();
}
}

function stopCount() {
clearTimeout(timeout);
timer_on = 0;
}




<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>setTimeout in JS</title>
</head>

<body>
<!-- Example2 -->
<button onclick="myFunction()">Press Me!</button>

<!-- Example3 -->
<button onclick="startCount()">Start Count!</button>
<input type="text" id="demo">
<button onclick="stopCount()">Stop Count!</button>

<script src="index.js"> </script>
</body>

</html>

webcontent
visit shbcf.ru