Animal Party

Dancing Animals!

HTML

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="style.css">
  <link rel="icon" href="icon.png">
  <title>AnimalParty</title>
</head>
<body>
  <img id="hamstergif" src="https://i.imgur.com/VcCu1wC.gif" alt="Hamster Dance">
  <table id="table"> 
    <tr>
      <td id="td1"></td>
      <td id="td2"></td>
      <td id="td3"></td>
      <td id="td4"></td>
      <td id="td5"></td>
      <td id="td6"></td>
      <td id="td7"></td>
      <td id="td8"></td>
    </tr>
    <tr>
      <td id="td9"></td>
      <td id="td10"></td>
      <td id="td11"></td>
      <td id="td12"></td>
      <td id="td13"></td>
      <td id="td14"></td>
      <td id="td15"></td>
      <td id="td16"></td>
    </tr>
    <tr>
      <td id="td17"></td>
      <td id="td18"></td>
      <td id="td19"></td>
      <td id="td20"></td>
      <td id="td21"></td>
      <td id="td22"></td>
      <td id="td23"></td>
      <td id="td24"></td>
    </tr>
    <tr>
      <td id="td25"></td>
      <td id="td26"></td>
      <td id="td27"></td>
      <td id="td28"></td>
      <td id="td29"></td>
      <td id="td30"></td>
      <td id="td31"></td>
      <td id="td32"></td>
    </tr>
    <tr>
      <td id="td33"></td>
      <td id="td34"></td>
      <td id="td35"></td>
      <td id="td36"></td>
      <td id="td37"></td>
      <td id="td38"></td>
      <td id="td39"></td>
      <td id="td40"></td>
    </tr>
    <tr>
      <td id="td41"></td>
      <td id="td42"></td>
      <td id="td43"></td>
      <td id="td44"></td>
      <td id="td45"></td>
      <td id="td46"></td>
      <td id="td47"></td>
      <td id="td48"></td>
    </tr>
  </table>
  <div id="container">
    <input id="beargif" width:48px; height="48px"; type="image" src="https://media2.giphy.com/media/1dIWQ3G8RQHFwSZ3wi/200w.gif?cid=82a1493bd2beuibpv5i7w0fv5q2an3y7ctvj8skqif8z3fhn&rid=200w.gif&ct=s" alt="Bear Dance">
    <input id="duckgif" width:48px; height="48px"; type="image" src="https://c.tenor.com/3arJZZkFW6kAAAAi/dancing-duck-danse.gif">
   ...

CSS

html {
  max-width: 254px; 
}

#hamstergif {
  position: absolute;
  width: 48px;
  height: 48px;
}

#beargif, duckgif, cowgif, pandagif {
  position: relative;
}

#container {
  max-width: 234px;
}

#button {
  width: 234px;
  height: 48px;
}

td {
  height:25px;
  width:25px
}

JavaScript

const leftPosition = (Math.floor(Math.random() * (190 - 10 + 1) + 10));
const topPosition = (Math.floor(Math.random() * (130 - 10 + 1) + 10));

const interval = 2000;

const bearId = "beargif"
const hamsterId = "hamstergif"
const duckId = "duckgif"
const cowId = "cowgif"
const pandaId = "pandagif"

function disco(){
  for (let i = 1; i <= 48; i++) {
    const randomColor = '#'+ Math.floor(Math.random()*16777215).toString(16);
    document.getElementById("td" + i + "").style.backgroundColor = randomColor;
  }
}

function resetColor() {
    const randomColor = "hsl(" + 360 * Math.random() + ',' + (25 + 70 * Math.random()) + '%,' + (85 + 10 * Math.random()) + '%)'
    document.getElementById("button").style.backgroundColor = randomColor;
}

function positionAnimal(animalId) {
	document.getElementById(animalId).style="position:absolute; left:" + leftPosition + "px; top:" + topPosition + "px;";
}


resetColor();
positionAnimal(hamsterId);
disco();

setInterval("disco();", 750);
setInterval("resetColor();", 750);
setInterval("positionAnimal(hamsterId);", interval);

document.getElementById("button").onclick = () => window.location.reload();


document.getElementById(bearId).onclick = () => positionAnimal(bearId);

function bearFunc() {
  positionAnimal(bearId);
  setInterval("positionAnimal(bearId);", interval) 
}

document.getElementById(duckId).onclick = () => positionAnimal(duckId);

function duckFunc() {
  positionAnimal(duckId)
  setInterval("positionAnimal(duckId)", interval) 
}

document.getElementById(cowId).onclick = () => positionAnimal(cowId);

function cowFunc() {
  positionAnimal(cowId)
  setInterval("positionAnimal(cowId)", interval) 
}

document.getElementById(pandaId).onclick = () => positionAnimal(pandId);

function pandaFunc() {
   positionAnimal(pandaId)
   setInterval("positionAnimal(pandaId)", interval) 
}