I’ve been trying to apply background image to a div via the jquery.css() function, such as:
$(‘#div’).css(‘backgrounds-image’,’./assets/imgs/flag.png’);
I’ve tried:
$(‘#div’).css(‘backgrounds image’,’./assets/imgs/flag.png’);
Expected: to see the image being displayed on the div., but it didn’t work.
HTML:
<div class="img-viewer"></div>
CSS:
div.img-viewer {
min-width: 200px;
min-height: 200px;
background-image: none;
background-repeat: no-repeat;
}
JQuery:
$('div.img-viewer').css('background-image','./assets/imgs/flag.png');