jquery 슬라이드 쇼를 사용하여 배경 이미지를 회전 시켰습니다. 하지만 제 요구 사항은 특정 날짜에 따라 배경 이미지를 표시해야한다는 것입니다. 나는 한 번에 한 이미지를 회전해야하고, 세 번, 그리고 세 번 이상 이렇게 회전시켜야한다는 것을 의미합니다. 이 스크립트에서는 매번 스크립트를 변경해야합니다. 스크립트를 변경하지 않고 어떻게 배경 이미지를 동적으로 회전시킬 수 있습니까? 누구든지 솔루션을 PLZ 내게 몇 가지 샘플 스크립트를 제안했다면. 나는 아래 위 script.And에 봉착바디 배경 이미지 회전은 동적 이미지 수를 지원해야합니다.
var slideshowSpeed = 6000;
var photos = [
{image1.png},
{image2.png},
{image3.png}
];
$(document).ready(function() {
$("#back").click(function() {
stopAnimation();
navigate("back");
});
$("#next").click(function() {
stopAnimation();
navigate("next");
});
var interval;
$("#control").toggle(function() {
stopAnimation();
}, function() {
$(this).css({"background-image":"url(images/btn_pause.png)"});
navigate("next");
interval = setInterval(function() {
navigate("next");
}, slideshowSpeed);
});
var activeContainer = 1;
var currentImg = 0;
var animating = false;
var navigate = function(direction) {
if (animating) {
return;
}
if (direction == "next") {
currentImg++;
if (currentImg == photos.length + 1) {
currentImg = 1;
}
} else {
currentImg--;
if (currentImg == 0) {
currentImg = photos.length;
}
}
var currentContainer = activeContainer;
if (activeContainer == 1) {
activeContainer = 2;
} else {
activeContainer = 1;
}
showImage(photos[currentImg - 1], currentContainer, activeContainer);
};
var currentZindex = -1;
var showImage = function(photoObject, currentContainer, activeContainer) {
animating = true;
currentZindex--;
$("#headerimg" + activeContainer).css({"background-image":"url(images/" + photoObject.image + ")","display":"block","z-index":currentZindex});
$("#headertxt").css({"display":"none"});
$("#firstline").html(photoObject.firstline);
$("#secondline").attr("href", photoObject.url).html(photoObject.secondline);
$("#pictureduri").attr("href", photoObject.url).html(photoObject.title);
$("#headerimg" + currentContainer).fadeOut(function() {
setTimeout(function() {
$("#headertxt").css({"display":"block"});
animating = false;
}, 500);
});
};
var stopAnimation = function() {
$("#control").css({"background-image":"url(images/btn_play.png)"});
clearInterval(interval);
};
navigate("next");
interval = setInterval(function() {
navigate("next");
}, slideshowSpeed);
});
당신은 현재 날짜를 기준으로 var photos
을 반환하는 간단한 자바 스크립트 함수를 만들 수 있습니다 내 HTML
<div id="headerimgs">
<div id="headerimg1" class="headerimg"></div>
<div id="headerimg2" class="headerimg"></div>
<div id="headerimg3" class="headerimg"></div>
</div>
여기에 코드를 넣으십시오. – HardCode
@HardCode 여기에 내 코드를 추가했습니다. – Valli69
요일 순환 패턴은 무엇입니까? 수식이라고 말할 수 있습니까? – Elen