简体   繁体   中英

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?

希望这个能对您有所帮助

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM