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,228
  • 2
  • 21
  • 33
Tom McClean
  • 445
  • 1
  • 8
  • 25
  • 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

3

The image needs to be within url ()

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

It needs be set like:

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