I have the following code, where the is placed after my that it refers to in the HTML file (both inside of ), but the browser is still giving the attached error.
<body>
<div id="container" class="fancy" draggable="false">
<span id="l1" class="fly">A</span>
<span id="l2" class="fly">B</span>
<span id="l3" class="fly">O</span>
<span id="l4" class="fly">U</span>
<span id="l5" class="fly">T</span>
</div>
<script>
function hoverWord() {
for (let i = 1; i < 7; i++) {
let letter = document.getElementById("l" + i.toString());
let x = Math.floor(Math.random() * 200) - 100;
let y = Math.floor(Math.random() * 200) - 100;
let deg = Math.floor(Math.random() * 100) - 50;
letter.style.translate = `${x}% ${y}% `;
letter.style.rotate = `${deg}deg`;
}
//document.getElementById("container").style.boxShadow = "120px 80px 40px 20px #0ff;";
}
function resetWord() {
for (let i = 1; i < 7; i++) {
let letter = document.getElementById("l" + i.toString());
letter.style.translate = `0% 0% `;
letter.style.rotate = `0deg`;
}
}
let container = document.getElementById("container");
container.addEventListener("mouseenter", () => {
hoverWord();
});
</script>
</body>
Error Message:
I’ve tried placing the inside of the , before the , after the and after the tag, but I still get the same error.
New contributor
HanYildirim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1