我有这些代码:
<script type="text/javascript">
var screenWidth = window.screen.width;
var width_sides = (screenWidth - 980) / 2;
</script>
<div id="not_important" width=""></div>
我想将div的宽度设置为等于javascript tagg中等式的结果。我怎么能这样做?
由于
答案 0 :(得分:2)
<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>