我写了一个小的'新闻速递'。我应该通过spans
进行循环,每5秒进行一次fadeIn/fadeOut。jQuery滑块 - 意外行为
虽然未触及,但它运行良好,但是当您尝试玩箭(例如向前跳5次)时,脚本会发疯使fadeIn/fadeOut不动。
脚本:
(function($) {
$.fn.NoticeBoard = function() {
// Set a timeout
var timeOut = setTimeout(nextNotice, 5000);
// pause on hover
$('.noticeboard').hover(
function() {
clearTimeout(timeOut);
}, function() {
timeOut = setTimeout(nextNotice, 5000);
});
// Next notice function called on timeout or click
function nextNotice(event) {
clearTimeout(timeOut);
timeOut = setTimeout(nextNotice, 5000);
if ($('.noticeboard span:visible').is('.noticeboard span:last-child')) {
$('.noticeboard span:visible').fadeOut(300);
$('.noticeboard span:first-child').fadeIn();
}
else {
$('.noticeboard span:visible').fadeOut(300).next().fadeIn();
}
return false;
}
$('#notice-next').click(nextNotice);
$('#notice-prev').click(function(event) {
if ($('.noticeboard span:visible').is('.noticeboard span:first-child')) {
$('.noticeboard span:visible').fadeOut(300);
$('.noticeboard span:last-child').fadeIn();
}
else {
$('.noticeboard span:visible').fadeOut(300).prev().fadeIn();
}
return false;
});
};
/*!
---------------------------------------------*/
})(jQuery);
/*! OnLoad
---------------------------------------------*/
$(document).ready(function() {
$('.noticeboard span').hide();
$('.noticeboard span:first').show();
$('.noticeboard').NoticeBoard();
});
与固定大加赞赏问题的任何帮助。
FF 6.0,Chrome 15等。 – Iladarsda