コードに問題があります。そのため、interval の値を 9 から current_interval の値に変更しようとしています。これは、クリック イベントを介して発生します。しかし、ChangePicture() 関数が開始されるとき、間隔はまだ 9 です (基本的に、5 秒後に画像を変更する画像回転スクリプトがあります)。
var interval = 9;
var globalCounter = 0;
var temp = setInterval(function() {ChangePicture()}, 5000);
function SetInterval(i)
{
interval = i;
}
$(document).on("click", ".picture_button_lol", function(event){
var current_interval = $(this).children(".amount_of_pictures").val();
SetInterval(current_interval);
});
function ChangePicture()
{
var pictureId = globalCounter%interval;
ShowAndHide(pictureId);
globalCounter = globalCounter + 1;
}
function ShowAndHide(picId)
{
var picture = "bigview_" + picId;
var text = "bigview_text_" + picId;
var button = "bigview_button_" + picId;
var z_index = 1;
document.getElementById(picture).style.zIndex = z_index;
document.getElementById(text).style.zIndex = z_index;
document.getElementById(button).style.backgroundColor = "#ffffff";
document.write(interval);
for(var i=0; i<interval; i++)
{
if(i != picId)
{
picture = "bigview_" + i;
text = "bigview_text_" + i;
button = "bigview_button_" + i;
z_index = 0;
document.getElementById(picture).style.zIndex = z_index;
document.getElementById(text).style.zIndex = z_index;
document.getElementById(button).style.backgroundColor = "#000000";
}
}
globalCounter = picId;
}