2
<button class='botao' id='btnCriar' onClick="gerarQuadrado()">Gerar novo</button>
<div id="app">
<div class="box"></div>
</div>
<script>
var btnCriar = document.querySelector('#btnCriar')
btnCriar.style.color = '#fff'
btnCriar.style.fontWeight = 'bold';
btnCriar.style.backgroundColor = '#424242';
btnCriar.style.border = 'solid #ddd';
btnCriar.style.width = '200px';
btnCriar.style.height = '40px';
btnCriar.style.marginLeft = '45%';
btnCriar.onclick = function gerarQuadrado() {
var boxElement = document.querySelector('.box');
boxElement.style.width = '180px';
boxElement.style.height = '180px';
boxElement.style.margin = '10px';
boxElement.style.backgroundColor = '#f00';
}
</script>
I’m caught in this part of generating a new square, at the moment it just generates an element.
When you say "a new square" you mean that there already is one or I’m wrong?
– user60252