スライドショー用の次のスクリプトに問題があります。現在は静的で、スライドが回転するように setInterval を含めることを目指しています。setIntervalを設定する適切な場所が見つからないため、ここでこのメソッドをより適切に実装する方法について何かアドバイスをいただけますか。
コードは次のとおりです。
<script type="text/javascript">
$(document).ready(function() {
var theImage = $('ul.photos li img');
var theWidth = theImage.width()
//wrap into mother div
$('ul.photos').wrap('<div id="mother" />');
//assign height width and overflow hidden to mother
$('#mother').css({
width: function() {
return theWidth;
},
height: function() {
return theImage.height();
},
position: 'relative',
overflow: 'hidden'
});
//get total of image sizes and set as width for ul
var totalWidth = theImage.length * theWidth;
$('ul.photos').css({
width: function(){
return totalWidth;
}
});
$(theImage).each(
function(intIndex){
$(this).nextAll('a')
.bind("click", function(){
if($(this).is(".next")) {
$(this).parent('li').parent('ul').animate({
"margin-left": (-(intIndex + 1) * theWidth)
}, 1000)
} else if($(this).is(".previous")){
$(this).parent('li').parent('ul').animate({
"margin-left": (-(intIndex - 1) * theWidth)
}, 1000)
} else if($(this).is(".startover")){
$(this).parent('li').parent('ul').animate({
"margin-left": (0)
}, 1000)
}
});//close .bind()
});//close .each()
});
</script>
私はどんな答えにも非常に感謝します。