Reputation: 61
I have these codes:
<script type="text/javascript">
var screenWidth = window.screen.width;
var width_sides = (screenWidth - 980) / 2;
</script>
<div id="not_important" width=""></div>
I want to set the width of the div equal to the result from the equation inside the javascript tagg. How can I do that?
Thanks
Upvotes: -1
Views: 46
Reputation: 3079
<div id="not_important" width=""></div>
<script type="text/javascript">
var screenWidth = window.screen.width;
var width_sides = (screenWidth - 980) / 2;
document.getElementById('not_important').style.width = width_sides;
</script>
Upvotes: 1