-1
我需要同一条链路url(img/bg/06.jpg)
但jQuery的给我一个长链接一样url("file:///D:/WORKING%20FILE/One%20Landing%20Page/version/img/bg/06.jpg")
获取背景图片的URL从内联CSS与jQuery
这里是我的代码:
<div class="box_bg">
<div style="background-image: url(img/bg/06.jpg)" class="single_bg"></div>
<div style="background-image: url(img/bg/07.jpg)" class="single_bg"></div
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
<script>
$('.box_bg .single_bg').each(function() {
var bg_img = $(this).css('backgroundImage');
$(this).click(function() {
window.alert(bg_img);
});
});
</script>
你用内嵌样式只是工作,以及是否有定义的其它一些特性,除背景图像? – sinisake
我只使用内联样式工作..并没有 –