Oops guys I have a div that is my site header, I want to hide it by clicking a button and making it appear when clicking another button. I can hide it and the movement is the way I want it, but when it comes to showing it back it does not show the same fluidity and the image does not stay on the screen, disappearing at the end.
function myMove() {
var elem = document.getElementById("box-toogle");
var pos = 0;
var t = 0;
var id = setInterval(frame, 5);
function frame() {
if (pos == 160) {
clearInterval(id);
} else {
pos--;
elem.style.top = pos + 'px';
t++;
}
}
function myMove1() {
var elem = document.getElementById("box-toogle");
var pos = 150;
var t = 0;
var id = setInterval(frame, 5);
function frame() {
if (pos == 0) {
clearInterval(id);
} else {
pos--;
elem.style.top = pos + 'px';
t++;
}
}
#box-toogle {
width: 100%;
height: 150px;
position: relative;
}
<html>
<head>
</head>
<body>
<header id="box-toogle">texto</header>
</body>
</html>
I am a beginner in javascript, if you can help me thank you