1

I'm trying to change the css background style in JavaScript. I'm able to do this

div.style.backgroundImage = "url('img/bg1.png')";

but when I try to add these styles it doesn't work - it returns with this error

Uncaught SyntaxError: Unexpected token - (index):59

div.style.-webkit-background-size = cover;
div.style.-moz-background-size = cover;
div.style.-o-background-size = cover;
div.style.background-size = cover;

is it possible to do this in JavaScript?

2
  • Does this help? stackoverflow.com/a/8889149/4453045 Commented Jan 3, 2017 at 15:50
  • 1
    You cannot set the vendor specific CSS styles that way. In fact, you don't even need to set them. Commented Jan 3, 2017 at 15:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.