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%"});
1

2 Answers 2

2

The image needs to be within url ()

$("section.section-1653").css({"background-image": "url("+backgroundImageUrl+")", "font-size": "200%"});
Sign up to request clarification or add additional context in comments.

Comments

1

It needs be set like:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.