私はこのウェブページでカルーセルを持っていますhttps://stfn.herokuapp.comそれはほぼ完璧に動作し、中央にあるメイン(アクティブ)アイテムのみです。リダイレクトするはずです)jsファイルとインデックスの両方にリンクを追加しようとしましたが、誰かがヒントを得た問題を解決しませんでしたか?Jqueryカルーセルがアクティブなアイテムをクリックしてもリダイレクトされません
[編集]
はそれをやった、質問をする前に、最新のビルドをアップロードし忘れました。だから私は、index.htmlのimgにタグを追加しました。それはどちらもうまくいかないようです。ご覧のように、ここでは、コードのスニペットが
$('.carousel .item').click(function(e) {
var index = $(this).index('li');
carousel.cycleActiveTo(index);
// song3();
e.preventDefault();
if (currentIndex != index){
var difference;
if (currentIndex == 0 && index >= 5){
difference = (index - currentIndex) - 13;
} else {
difference = index - currentIndex;
}
difference = Math.abs(difference);
delay = difference * options.duration;
currentIndex = index;
console.log(delay);
setTimeout(goToLink, delay);
}
});
goToLink = function() {
if (currentIndex == 0) {
// console.log("works:");
document.location.href = "about.html"
}
if (currentIndex == 1) {
document.location.href = "blog.html"
}
else if (currentIndex == 2) {
document.location.href = "collection.html"
}
else if (currentIndex == 3) {
document.location.href = "shop.html"
}
else if (currentIndex == 4) {
// alert("ABOUT2");
document.location.href = "about.html"
}
else if (currentIndex == 5) {
document.location.href = "blog.html"
}
else if (currentIndex == 6) {
document.location.href = "collection.html"
}
else if (currentIndex == 7) {
document.location.href = "contact.html"
}
else if (currentIndex == 8) {
document.location.href = "shop.html"
}
else if (currentIndex == 9) {
document.location.href = "contact.html"
}
else if (currentIndex == 0) {
document.location.href = "about.html"
}
}
});
JSファイルからリダイレクトするためだ、すべての要素がそれに割り当てられたインデックスを持っており、それが特定のページに切り替えることができます。アクティブ項目のインデックス番号は0ですが、他の項目と同じようには機能していません。
いくつかのコードを示します。もちろん、何もしません。 'img'にはリンクがありません。 –
ああ、最新のビルドをアップロードするのを忘れた。また、リダイレクトを担当するコードを追加しました。 –
'goToLink' fnはひどいです。 :Dリンク/ページを配列に入れ、 'document.location.href = linkArray [currentIndex]'を呼び出してください –