j4pm/website/crab.js

21 lines
No EOL
698 B
JavaScript

const crab = () => {
let audio = document.createElement("audio");
audio.autoplay = "true";
audio.loop = "true";
let source = document.createElement("source");
source.src = "crab.mp3";
audio.appendChild(source);
let random = Math.floor(Math.random() * 35);
let boy = document.querySelector("body");
for (let i = 0; i < random; i++) {
let crab = document.createElement("h3");
crab.innerText = "🦀";
crab.className = "crab";
crab.style = `z-index: -3; left: ${Math.floor(Math.random() * 100)}vw; animation-duration: ${Math.random() * 10}s; animation-delay: 0s;`
boy.appendChild(crab);
}
boy.appendChild(audio);
}