retina.js for hardcoded css background-images

457 views Asked by At

i'm using using the css background-image attribute to display images. Those images are queried via ajax, therefore I know i am supposed to call this:

$('img').each(function(){new RetinaImage(this);});

after the images are loaded.

It works with images or the img tag, but since I need the background-image url() attribute to be updated – I am not sure how to do this.

I tried to change the JS to:

$('.myBackgroundImgClass').each(function(){new RetinaImage(this);});

for the div:

<div class="myBackgroundImgClass" style="background-image:url(..someImg.jpg);"></div>

but it does not seem to do the job. Any suggestions? Thanks!

0

There are 0 answers