我需要帮助修复我的jQuery脚本。我不确定jQuery的规则。运行此脚本后,我需要它循环。
<script>
$(document).ready(function(){
var $title = $('#banner-title span').replaceWith('Testimonials');
var $title2 = $('#banner-title span').replaceWith('Rental Program');
var $title3 = $('#banner-title span').replaceWith('Services');
$title.fadeIn('fast',function() {
$title.delay(7500).fadeOut('fast',function() {
$title2.fadeIn('fast',function() {
$title2.delay(7500).fadeOut('fast',function() {
$title3..fadeIn('fast',function() {
$title3.delay(7500).fadeOut('fast');
});
}
</script>
答案 0 :(得分:0)
var titles = ['My Title 1', 'My Title 2'], titleFlag = 0;
function BTTS(){
$('#banner-title span').fadeOut('fast',function() {
titleFlag = (titleFlag + 1) % titles.length;
$('#banner-title span').html(titles[titleFlag]).show();
}); //<-- missing ')' here
}
$(document).ready(function(){
// RUN BTTS FUNCTION
setInterval(BTTS, 2000);
}); //<-- missing ')' here
演示:Fiddle