特定のリンクをマウスオーバーするときにdivの内容を置き換えるコードをまとめています。その後、チェンジャー機能を追加してコンテンツの置換を自動的に繰り返しました。私はマウスオーバーとマウスアウトのフラグを設定して、実際にマウスオーバーで停止するチェンジャー機能を得ることができますが、マウスアウト時に再び起動させる方法を理解できません。アドバイスをいただければ幸いです。フラグによって再起動された後の再起動のループ
var pause=false;
$('.banner-nav a').mouseover(function() {
pause=true;
setFeature(this);
return false;
});
$('.banner-nav a').mouseout(function() {
pause=false;
});
changer(0, 5000);
function setFeature(f) {
var m = $(f).attr('rel');
$('.banner-nav a').not(f).removeClass('active');
$(f).addClass('active');
$('#featureContainer').html($(m).html());
}
function changer(index, interval) {
var buttons = $('.trigger'),
buttons_length = buttons.length;
var button = buttons.eq(index % buttons_length);
setFeature($(button));
setTimeout(function() {
if (!pause) {
changer(++index, interval);
}
}, interval)
}
の可能複製(http://stackoverflow.com/questions/2626005/)、[ジャバスクリプト:のsetTimeoutを(一時停止);] [setTimeoutメソッド呼び出しを一時停止する方法?](http://stackoverflow.com/question/3969475 /)、[Javascript setTimeout function](http://stackoverflow.com/questions/7191769/) – outis