0
I need to listen to an html element of id="hamburger", if the user clicks, javascript checks the value of the display property of another element, in the case id="Overlaynav", and changes the value, case display="None" turns into "block" and vice versa.
is giving syntax error, someone can exemplify how I make it happen?
I would like to make the whole box of my Overlaynav click sensitive, in case the user click on any screen area where there is no one <li>
, the Overlaynav display becomes "None" tbm
<!-- Script do OverlayNav -->
<script>
document.getElementById("hamburger").addEventListener("click", function() {
var status = OverlayNav.style.display = '';
if (status === 'none') {
var status = OverlayNav.style.display = 'block';
} else {
var status = OverlayNav.style.display = 'none';
}
});
</script>
like you said, you wouldn’t even need to create a new
var status
where is changing thedisplay
of the element, would be even better :)– Ricardo Pontual
@Ricardopontual vdd, in fact, is that as I started from his code I didn’t even tend to the details
– hugocsl
I get it. I actually think it’s really cool that animated gifs
– Ricardo Pontual
@Ricardopunctual is a 3MB program called Screentogif, super light and easy to use, recommend
– hugocsl
good recommendation, downloading here :)
– Ricardo Pontual
cool, it worked =D another detail, there is a script that changes the class of the hamburger button when clicked, this.classList.toggle("is-active"); when you click on the overlay box, it disappears but the button continues with the class ("is-active") how do I return the class of the button if the overlay is display:None ?
– Nicholas Affonso
@Nicholasaffonso in the function you click on the overlay vc puts in to remove the is-active class from the hamburger, would look like this for example
document.getElementById("hamburger").classList.remove('is-active');
, you have to run this when you click on the overlay– hugocsl
perfect, everything working accordingly
– Nicholas Affonso