我试图让我自己的图像旋转器,如果在屏幕上有多个图像旋转器,将工作。以下是我迄今为止得到:jquery将此传递给变量函数
// jQuery plugin to make image containers rotate.
(function($){
// Swap text with title attribute
$.fn.scWFWImageRotator = function() {
var rotatorTimeSwap = 6000;
$(this).find("img").removeClass("selected");
$(this).find("img:first-child").addClass("selected");
var rotatorImageChangeFunc = function(item) {
var rotatorImages = $(item).children("img");
var imgSelected = $(item).children("img.selected");
var rotatorImgCount = rotatorImages.length;
var rotatorCurImage = $(imgSelected).index(rotatorImages);
alert(item);
}
return this.each(function() {
var rotatorTimer;
var $this = $(this);
var func = $.proxy(rotatorImageChangeFunc, $this);
rotatorTimer = setInterval(func, rotatorTimeSwap);
$this.hover(
function() { rotatorTimer = clearInterval(rotatorTimer); },
function() { rotatorTimer = setInterval(func, rotatorTimeSwap); }
);
});
};
})(jQuery);
问题是:rotatorImageChangeFunc = function(item) {
项目不获取传递给函数。所以在这个函数里,我没有定义item。为什么会出现这种情况,我该如何解决?