Hjælp til at få dette jquery script til at køre automatisk og loope
Jeg har dette jscript fra fra lynda.com - det kører en nyhedsrotation med billeder og tekst med navigationsknapper - men kan ikke få det til at afvikle automatisk, nogen der kan hjælpe?$(document).ready(function(){
// Generate Navigation links
$('.marquee_panels .marquee_panel').each(function(index){
$('.marquee_nav').append('<a class="marquee_nav_item" ></a>');
});
// Generate Photo Lineup
$('img.marquee_panel_photo').each(function(index){
var photoWidth = $('.marquee_container').width();
var photoPosition = index * photoWidth;
$('.marquee_photos').append('<img class="marquee_photo" style="left: '+photoPosition+'" src="'+$(this).attr('src')+'" alt="'+$(this).attr('alt')+'" width="700" height="350" />');
$('.marquee_photos').css('width', photoPosition+photoWidth);
});
// Set up Navigation Links
$('.marquee_nav a.marquee_nav_item').click(function(){
// Set the navigation state
$('.marquee_nav a.marquee_nav_item').removeClass('selected');
$(this).addClass('selected');
var navClicked = $(this).index();
var marqueeWidth = $('.marquee_container').width();
var distanceToMove = marqueeWidth*(-1);
var newPhotoPosition = navClicked*distanceToMove + 'px';
var newCaption = $('.marquee_panel_caption').get(navClicked);
// Animate the photos and caption
$('.marquee_photos').animate({left: newPhotoPosition}, 1000);
$('.marquee_caption').animate({top: '340px'}, 500, function(){
var newHTML = $(newCaption).html();
$('.marquee_caption_content').html(newHTML);
setCaption();
});
});
// Preload all images, then initialize marquee
$('.marquee_panels img').imgpreload(function(){
initializeMarquee();
});
});
function initializeMarquee(){
$('.marquee_caption_content').html(
$('.marquee_panels .marquee_panel:first .marquee_panel_caption').html()
);
$('.marquee_nav a.marquee_nav_item:first').addClass('selected');
$('.marquee_photos').fadeIn(1500);
setCaption();
}
function setCaption(){
var captionHeight = $('.marquee_caption').height();
var marqueeHeight = $('.marquee_container').height();
var newCaptionTop = marqueeHeight - captionHeight - 15;
$('.marquee_caption').delay(100).animate({top: newCaptionTop}, 500);
}
