Answer the question
In order to leave comments, you need to log in
DevTools. How to catch the moment in onload when a class is added to an element?
Apparently, Break on attributes modifications does not work in onload, or I'm doing something wrong.
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
<link rel="stylesheet" href="style.css">
<script defer src="script.js"></script>
</head>
<body>
Hello, world!
</body>
</html>
body:before {
content: "ver 1."
}
body.ver2:before {
content: "ver 2."
}
body.ver3:before {
content: "ver 3."
}
function onready() {
b = document.getElementsByTagName("body")[0];
b.classList.add('ver2');
setTimeout(ver3, 3000);
}
function ver3() {
b.classList.add('ver3');
}
document.addEventListener('DOMContentLoaded', onready);
Answer the question
In order to leave comments, you need to log in
Try debugging the code with the debugger command.
function onready() {
debugger;
b = document.getElementsByTagName("body")[0];
b.classList.add('ver2');
setTimeout(ver3, 3000);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question