Javascript jquery在尝试设置背景图像时单击:url(数据:image;对于div为base64

Javascript jquery在尝试设置背景图像时单击:url(数据:image;对于div为base64,javascript,jquery,css,Javascript,Jquery,Css,这就是我正在尝试的 第一个div是带有数据:image;base64的html <div id="large_photo_null" style="width:50px; height:50px; background-image: url( data:image;base64,R0lGODlhR.. );" > </div> 怎么了?我的代码不正确或使用jquery无法设置数据:image;base64 现在发现了类似的话题 将选中jQuery的.css()接受如

这就是我正在尝试的

第一个div是带有
数据:image;base64的html

<div id="large_photo_null" style="width:50px; height:50px; 
background-image: url( data:image;base64,R0lGODlhR..  );" >
</div>
怎么了?我的代码不正确或使用jquery无法设置
数据:image;base64

现在发现了类似的话题

将选中jQuery的.css()接受如下参数:

$('div').css({'background':'000'});

尝试重新构造最后一行,看看是否有不同的行为。

jQuery的.css()接受如下参数:

$('div').css({'background':'000'});


试着重组你的最后一行,看看你是否有不同的行为。

经过两个小时的处理,这个解决方案对我很有效

var img = new Image();
img.src = "data:image/jpeg;charset=utf-8;base64, " + profilepic;
$("#profilepict").css("background-image", "url('" + img.src + "')");

经过两个小时的摆弄,这个解决方案对我有效

var img = new Image();
img.src = "data:image/jpeg;charset=utf-8;base64, " + profilepic;
$("#profilepict").css("background-image", "url('" + img.src + "')");

使用
background':“#000
有效。但是如何使用
数据:image;base64
而不是
#000
…将尝试。感谢您的想法这是预期的行为吗?我修改了jquery的最后一行以匹配我的,还删除了背景url结尾处的
:使用
background':“#000
有效。但是如何操作呢要使用
数据:image;base64
而不是
#000
…将尝试。感谢您的想法这是预期的行为吗?我修改了jquery的最后一行以匹配我的,还删除了背景url末尾的
var img = new Image();
img.src = "data:image/jpeg;charset=utf-8;base64, " + profilepic;
$("#profilepict").css("background-image", "url('" + img.src + "')");