JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<title>Site projet</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<link rel="stylesheet" href="page3style.css" />
</head>
<body>
<div id="squareRandomColor"></div>
<script src="page3fonctions.js"></script>
</body>
</html>
CSS
body{
margin: 100px;
}
#squareRandomColor{
width: 100px;
height: 100px;
position: relative;
top: 100px;
background-color: black;
}
JavaScript
function getRandomColor(){
return "#"+Math.floor(Math.random()*16777215).toString(16);
}
document.getElementById("squareRandomColor").addEventListener("click",getRandomColor());