I am trying to set an inline style property of a div using javascript. This seems to work to get the value to an alert window:
<!-- /returns 890px for me -->
<script>
alert(screen.height - 10 +"px");
</script>
However, this does not set the style for the div with the ID used:
<script>
document.getElementById("page-wrapper").style.min-height = screen.height - 10 +"px";
</script>
Neither does this:
<script>
document.getElementById("page-wrapper").style.min-height = screen.height - 10 +"px";
</script>
Any help would be appreciated.
Use camelCasing for CSS styles in JS
<script>
document.getElementById("page-wrapper").style.minHeight = screen.height - 10 +"px";
</script>
You're close. The property is camel-cased without a hyphen, like:
<script>
document.getElementById("page-wrapper").style.minHeight = screen.height - 10 + "px"
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With