1

我想在内联样式声明中使用 javascript 变量 screen 作为样式背景属性。

<div id ="content" style=" position: relative; top: -400px;  left: 0px;  width: 60px; height: 400px; z-index: 901;background-image: url(' + screen + ') "></div>
4

1 回答 1

1
document.write('<div id ="content"
  style="
    position: relative;
    top: -400px;
    left: 0px;
    width: 60px;
    height: 400px;
    z-index: 901;
    background-image: url(' + screen + ')
  ">
</div>')

或者

document.getElementById('content').style.backgroundImage = screen;
于 2013-03-09T18:09:06.257 回答