Medoju Narendar Medoju Narendar - 5 months ago 17
jQuery Question

Set background-image using jQuery css property

I am able to load image in div but I want load as background image using jQuery.

Here is my code:

src = 'image.jpg';

$(".imagePreview").html(src ? "<img src='" + ImagePath + src + "'>" : "");


Any help?

Answer

hope this will help you

$('.imagePreview').css('background-image', 'url(' + imageUrl + ')');
Comments