What I am trying to do is change the background-image of a div, but only if the background-image url matches a certain url.
Here is the HTML:
<div class="test" style="background-image: url("/background1.png");">
Now what I've tried is this:
if ($('.test').css('background-image') === 'url(/background1.png)') {
$('.test').css("background-image", "url(/background2.png)");
}
I know that the replace works, because if I remove the first line it updates all the background images for me, but I can't seem to get the first line to work.