Вот этот код в целом не работает.
function headone() {
document.getElementById("headone").style.opacity = '1';
}
function headtwo() {
document.getElementById("headtwo").style.opacity = '1';
}
function headthree() {
document.getElementById("headthree").style.opacity = '1';
}
function head() {
headone();
setTimeout(function() {
headtwo();
setTimeout(headthree, 1000);
}, 1000);
}
window.addEventListener("load", headone);
<div style="font-size: 33px; opacity: 0; transition: 4s ease" id="headone">Текст
</div>
<div style="font-size: 33px; opacity: 0; transition: 4s ease" id="headtwo">Текст
</div>
<div style="font-size: 33px; opacity: 0; transition: 4s ease" id="headthree">Текст
</div>
Надо не
window.addEventListener("load", headone);
a
window.addEventListener("load", head);
Молодец, что не сдавался!
Неправильный устаревший ответ:
На странице нет элемента с id="headtwo".
function headone() {
document.getElementById("headone").style.opacity = '1';
console.log("headone");
}
function headtwo() {
document.getElementById("headtwo").style.opacity = '1';
console.log("headtwo");
}
function headthree() {
document.getElementById("headthree").style.opacity = '1';
console.log("headthree");
}
function head() {
headone();
setTimeout(function() {
headtwo();
setTimeout(headthree, 1000);
}, 1000);
}
window.addEventListener("load", head)
<div style="font-size: 33px; opacity: 0; transition: 4s ease" id="headone">Текст One
</div>
<div style="font-size: 33px; opacity: 0; transition: 4s ease" id="headtwo">Текст Two
</div>
<div style="font-size: 33px; opacity: 0; transition: 4s ease" id="headthree">Текст Three
</div>
При наличии на странице элементов с id headone, headtwo, headthree все работает
function headone() {
document.getElementById("headone").style.opacity = '1';
}
function headtwo() {
document.getElementById("headtwo").style.opacity = '1';
}
function headthree() {
document.getElementById("headthree").style.opacity = '1';
}
function head() {
headone();
setTimeout(function() {
headtwo();
setTimeout(headthree, 1000);
}, 1000);
}
window.addEventListener("load", head);
<div style="font-size: 33px; opacity: 0; transition: 4s ease" id="headone">Текст
</div>
<div style="font-size: 33px; opacity: 0; transition: 4s ease" id="headtwo">Текст
</div>
<div style="font-size: 33px; opacity: 0; transition: 4s ease" id="headthree">Текст
</div>
Update
У вас проблема в этой строке
window.addEventListener("load", headone);
Вы при загрузке страницы вызываете не общую функцию, а функцию отображения первого элемента. Измените ее на
window.addEventListener("load", head);
и все будет работать
Апостиль в Лос-Анджелесе без лишних нервов и бумажной волокиты
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости