値に基づいてこのjQuery関数を使用して、4つのdivを10秒間切り替えていa href id
ます。
タイマーは正常に動作し、10 秒ごとに 4 つの div を変更しますが、ユーザーが特定の div をクリックすると、特定の div に移動せず、特定の期間 (例: 10 秒) の間そこにとどまり、代わりに現在の div から次の div に進みます。タイマー値に基づいてdivに移動すること。
誰でもこれに関して私を助けることができますか?
$(function() {
$("a.menu").click(function() {
$("div.featuredposts_content").hide();
$($(this).attr('href')).show();
return false;
});
});
$(function() {
var counter = 0,
divs = $('#cat1, #cat2, #cat3,#cat4');
function showDiv() {
divs.hide() // hide all divs
.filter(function(index) {
return index == counter % 4;
}) // figure out correct div to show
.show('fast'); // and show it
counter++;
}; // function to loop through divs and show correct div
showDiv(); // show first div
setInterval(function() {
showDiv(); // show next div
}, 15 * 1000); // do this every 10 seconds
});