此功能正常工作,
window.setInterval(function(){
var active = $('#frontpageControls a.active');
var next = active.next().length > 0 ? active.next() : $('#frontpageControls .first');
active.removeClass("active");
next.addClass("active");
var activeFPElement=$("#MainFrontpage li:visible");
var nextFPElement = activeFPElement.next().length > 0 ? activeFPElement.next() : $('#MainFrontpage .first');
activeFPElement.hide();
nextFPElement.show();
//alert($next.text());
}, 5000);
但是,当我在此运行相同的命令时
$("#frontpageArrows .right").bind("click", function() {
var active = $('#frontpageControls a.active');
var next = active.next().length > 0 ? active.next() : $('#frontpageControls .first');
active.removeClass("active");
next.addClass("active");
var activeFPElement=$("#MainFrontpage li:visible");
console.log(activeFPElement+ " Fpelement ");
var nextFPElement = $activeFPElement.next().length > 0 ? $activeFPElement.next() : $('#MainFrontpage .first');
activeFPElement.hide();
nextFPElement.show();
return false;
});
该函数无法正常运行,并且我收到一个错误,即 activeFPElement 未定义。谁能帮我解释为什么这个函数作为 setInterval 的处理程序而不是绑定的处理程序?
谢谢 :)