这条线不起作用
$('#bookcontainer').load( startSlide );
Run Code Online (Sandbox Code Playgroud)
而这条线确实如此
$(window).load( startSlide );
Run Code Online (Sandbox Code Playgroud)
#bookcontainer是一个div包含四个图像.
这是我的整个代码:
// JavaScript Document
$('#bookcontainer').load( startSlide );
var slide;
$('#slider').hover(
function() {
$('.arrow').show();
},
function() {
$('.arrow').hide();
});
function startSlide() {
$('.book').show();
slide = setInterval(slideR, 5000);
}
function slideR() {
$('.book').first().css('left', '960px').appendTo('#bookcontainer').animate(
{
"left": "-=960px"
}, {
duration: 1000,
easing: 'easeOutCubic'
});
}
function slideL() {
$('.book').last().animate(
{ "left":"+=960px" }, {
duration: 1000,
easing: 'easeOutCubic',
complete: function() {
$(this).prependTo('#bookcontainer').css('left', '0px');
}
});
}
function right() {
clearInterval(slide);
slideR(); …Run Code Online (Sandbox Code Playgroud)