我正在使用codeigniter我的文件夹结构。
application
assets
css
js
img
system
index.php
我要使我的自举旋转木马全窗高度。 我的方法是使用jquery使我的div.item图层达到窗口的完整高度。 然后从div.item图层中删除图像,并使用jquery将此图像设置为div.item背景图像。
这是我的jquery代码。
$('.carousel').find('.item img').each(function () {
var $this = $(this),
src = $(this).attr('src');
imageName = 'url(assets/img/' + $(this).attr('src').split('/')[6]+')';
$this.parent().css('background-image',imageName);
$this.remove();
});
我的不工作提示请告诉我我的代码有什么问题。
答案 0 :(得分:0)
你应该使用完整的参考。试试这个。
$('.carousel').find('.item img').each(function () {
var $this = $(this),
src = $this.attr('src');
$this.parent().css('background-image',src);
$this.remove();
});