到 document.ready() 时,该元素已在 HTML 中,但前面对“anything-slider”的调用存在问题。此后,我对其进行了如下评论,以在执行其他任何操作之前检查滑块是否存在。现在工作。感谢您的帮助和建议安迪,即使这不是解决方案。
$(document).ready(function () {
if($('#slider').length > 0) {
$('#slider')
.anythingSlider({
navigationFormatter : function(index, panel){
return ['Slab', 'Parking Lot', 'Drive', 'Glorius Dawn', 'Bjork?', 'Traffic Circle'][index - 1];
},
buildStartStop: false,
buildNavigation: true,
autoPlay: true
})
.anythingSliderFx({
'.caption-top' : [ 'caption-Top', '50px' ],
})
}
//Add modal functionality where class is set
$('.modal-inline').colorbox({transition:'elastic', speed:500, width:'80%', height:'50%', inline:true});
$('.modal-image').colorbox({transition:'elastic', speed:500, width:'80%', height:'50%', inline:false});
$('.modal-image-square').colorbox({transition:'elastic', speed:500, width:'1000', height:'1000', inline:false});
});