1

i want to use a javascript variable screen as style backgroundattribute in a inline style declaration.

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

1 Answer 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>')

or

document.getElementById('content').style.backgroundImage = screen;
Sign up to request clarification or add additional context in comments.

1 Comment

i wondered if it could be done as in my code but it cant i presume.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.