我想在内联样式声明中使用javascript变量屏幕作为样式backgroundattribute。
<div id ="content" style=" position: relative; top: -400px; left: 0px; width: 60px; height: 400px; z-index: 901;background-image: url(' + screen + ') "></div>
答案 0 :(得分: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;