Вот код целиком
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="container"></div>
<button id="but"></button>
<script>
var button = document.getElemetById('but');
function draw() {
var square = document.createElement('div');
var container = document.getElementById('container');
container.appendChild(square);
square.classList.add('square');
}
button.addEventListener("click", draw);
</script>
</body>
</html>