I am attempting to set the background-image using img src when media queries are activated.
My media queries kick in at a max-width of 854px.
I have been trying to achieve this with jQuery but it doesn't seem to be working.
This is my jQuery code:
$(document).ready(function () {
if ($(window).width() <= 854) {
$('a.class').css('background-image', 'url(' + $('a.class img').attr(src) + ')');
}
});
Can someone please help me figure out what I am doing wrong?
Thank you!