Hello world. I have a script that runs
Printing text with a delay, but through checkbox inclusions. I need to
Printing of the text began after some time
after the entire page loads. Knowledge of JS is almost zero.
Script code
Printing text with a delay, but through checkbox inclusions. I need to
Printing of the text began after some time
after the entire page loads. Knowledge of JS is almost zero.
Script code
Code:
"use strict";
window.onload = function () {
var i = 2;
var timer = setInterval(function () {
i--;
document.getElementById('timer') + i;
if (i == 0) {
document.getElementById('example').style.display = 'block';
document.getElementById('timer').style.display = 'none';
clearInterval(timer);
}
}, 1000)
}
var textNodes = [];
var textNodes_data = [];
var i = 0;
var d = document.getElementById('test');
search_textNodes(d);
document.querySelector('.envelope__check').onchange = function() {
if(this.checked) setTimeout(str_write, 2000);//время задержки печати
};
function search_textNodes(b) {
b = b.childNodes;
for (var c = 0, d = b.length; c < d; c++) {
var a = b[c];
if (a.nodeType == 3) {
textNodes.push(a);
textNodes_data.push(a.data);
a.data = "";
} else {
if (a.hasChildNodes()) search_textNodes(a);
}
}
}
function str_write() {
var a = textNodes_data[i];
если (a) {
textNodes[i].data += a.charAt(0);
textNodes_data[i] = a.substr(1);
} else i++;
if (i < textNodes.length) setTimeout(str_write, 90);
}
[/КОД]