1
Good Afternoon!
Next, I have a div.minhaDiv with a height: 580px; and I want to click on a button the height of that div.minhaDiv increase to 1600px.
When she is with height: 1600px I want to click on it button the height goes back to 580px;
Follows HTML
<div class="minhaDiv">
...
</div>
<button onclick="verMais();" class="botao">Ver mais</button>
Javascript
var altura = document.querySelector(".minhaDiv");
function verMais(){
if(altura.style.height <= "580px"){
altura.style.height = "1600px";
document.querySelector(".botao").innerHTML = "Ver menos";
}else{
altura.style.height = "580px";
document.querySelector(".botao").innerHTML = "Ver mais";
}
}
Can anyone tell me where I’m going wrong? Thanks a lot guys, and it sure is something very basic, I’m learning javascript, thanks a lot!