2

I have some Javascript which fires after an Ajax post.

When the javascript fires I want the <section class="section-1653"> to be given a different background image to the one specified in the CSS file.

I am running the following code and I can see the Font Size being set, but the background image is not.

Why is the background image property not being set?

$("section.section-1653").css({"background-image": backgroundImageUrl,font-size": "200%"});
stark
  • 2,246
  • 2
  • 23
  • 35
  • Possible duplicate of [Changing background image using jquery](http://stackoverflow.com/questions/4578714/changing-background-image-using-jquery) – Mr. Meeseeks Jan 28 '16 at 21:58

2 Answers2

2

The image needs to be within url ()

$("section.section-1653").css({"background-image": "url("+backgroundImageUrl+")", "font-size": "200%"});
dexhering
  • 422
  • 3
  • 13
1

It needs be set like:

$("section.section-1653").css({"background-image", "url('+ imageUrl +'), "font-size": "200%"});