본문 바로가기

프로그래밍 공부/프론트엔드

Web Development: JavaScript - setTimeout(function)

728x90


function buttonAnimation(currentKey) {
var activeButton = document.querySelector("." + currentKey);

activeButton.classList.add(".pressed");

setTimeout(function() {
activeButton.classList.remove("pressed");
}, 100);




setTimeout (function, milliseconds, param1, param2, ...)

funct

function buttonAnimation(currentKey) {
var activeButton = document.querySelector("." + currentKey);

activeButton.classList.add(".pressed");

setTimeout(function() {
activeButton.classList.remove("pressed");
}, 100);




setTimeout (function, milliseconds, param1, param2, ...)

function: required - the function that will be executed
milliseconds: optional. The number of milliseconds to wait before executing the code. If omitted, the value 0 is used
param1, param2, ... : optional. Additional parameters to pass