我想在 wordpress 中制作幻灯片,但由于某种原因它不起作用:
我的 .js 文件:
(function ($) {
function slideSwitch() {
var $active = $('#gallery1 IMG.active');
if ( $active.length == 0 ) $active = $('#gallery1 IMG:last');
var $next = $active.next().length ? $active.next()
: $('#gallery1 IMG:first');
$active.addClass('last-active');
$next.css({opacity: 0.0})
.addClass('active')
.animate({opacity: 1.0}, 1000, function() {
$active.removeClass('active last-active');
});
}
$(function() {
setInterval( "slideSwitch()", 5000 );
});
});
CSS 样式:
#gallery1{
position: relative;
width:400px;
height:300px;
}
#gallery1 img{
position:absolute;
z-index:8;
}
#gallery1 img.active{
z-index:10;
}
#gallery1 img.last-active{
z-index:9;
}
html代码:
<div id="gallery1">
<img src="img1.jpg" class="active"/>
<img src="img2.jpg"/>
<img src="img3.jpg"/>
</div>
Chromes 开发者工具不会显示任何错误。虽然萤火虫,显示此错误:错误断点:
但我不明白第一张图片有什么问题,它加载得很好。有没有人看到问题?