I’m trying to make a function that changes the CSS to the current height when I click a button. It won’t read the current height.
var height = $(window).height();
function openNav() {
document.getElementById("bodypacity").style.height = height;
}
#bodypacity {
width: 100%;
background-color: black;
opacity: 0.4;
position: absolute;
z-index: 999;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="menunav"> <span id="menu" style="" onclick="openNav()">☰</span>
<a href="index.html"><img id="logo" src="logo.png"></a>
</ul>
openNavcalled? Please provide a minimal reproducible example.bodypacityelement?