hint
/
main.js
22 строки · 570.0 Байт
1const HINT_CLASS = 'hint__show'2
3/**
4* @param {number} ms
5* @returns {Promise}
6*/
7const delay = ms => new Promise(resolve => setTimeout(resolve, ms))8
9/** @param {HTMLDivElement} hint */
10const show = hint => hint.classList.add(HINT_CLASS)11
12/** @param {HTMLDivElement} hint */
13const hide = hint => hint.classList.remove(HINT_CLASS)14
15/** @param {HTMLDivElement} hint */
16const showHideHandler = hint => delay(1000)17.then(show.bind(null, hint))18.then(delay.bind(null, 3000))19.then(hide.bind(null, hint))20
21document.querySelectorAll('.hint')22.forEach(showHideHandler)23