【发布时间】:2015-02-08 17:40:42
【问题描述】:
这里http://jsfiddle.net/m3e1kdzu/9/是我正在尝试的
第一个 div 是带有data:image;base64的html
<div id="large_photo_null" style="width:50px; height:50px;
background-image: url( data:image;base64,R0lGODlhR.. );" >
</div>
使用 html,我可以看到预期的背景图像。
现在尝试为另一个 div 设置背景图片。但没有变化。无法设置
这里是代码
<div id="large_photo" style="width:100px; height:150px;" >
This is as if large photo where expect to change background
</div>
<div class="thbn_photo" style="width:100px; height:150px;" >
As if thumbnail photo. Click here.
</div>
这里是jquery
$(document).on('click', '.thbn_photo', function(){
alert('thbn_photo clicked');
$('#large_photo').css( 'background-image: url( data:image;base64,R0lGODlhRgAzAJEAAMr.. );' );
});
怎么了?我的代码不正确或者用jquery不能设置data:image;base64?
现在发现类似话题Is there a way to set background-image as a base64 encoded image in javascript?
会检查
【问题讨论】:
标签: javascript jquery css