$(this).jquery插件中的each(function())返回DOM[]对象,而不是此对象

$(this).jquery插件中的each(function())返回DOM[]对象,而不是此对象,jquery,Jquery,这是我的插件的代码 $.fn.slide = function(settings) { return $(this).each(function() { setInterval(function() { $.slider(opt.direction , opt.slideSpeed,this) } } jQuery.slider = function(direction,slideSpeed,elm) { console.log(elm) - > shows D

这是我的插件的代码

$.fn.slide = function(settings) {

return $(this).each(function() {
    setInterval(function() { $.slider(opt.direction , opt.slideSpeed,this) }
}

jQuery.slider = function(direction,slideSpeed,elm) {
        console.log(elm) - > shows DOMWindow[] window as object 
    }

}


script.js   
$('#container').slide({
    slideAnimationTimeInterval : 6000,
    slideSpeed : 700,

}); 

console.log(elm)->将DOMWindow[]窗口显示为对象,但我需要#container object如何获取它?

嵌套函数时,需要将此保存在另一个变量中,如下所示:

return $(this).each(function() {
    var self = this;
    setInterval(function() { $.slider(opt.direction , opt.slideSpeed, self); }
}

是函数的上下文,默认情况下它是全局对象
窗口
。jQuery在调用函数时将其设置为更有用的对象(例如
.each()
)中的元素。但是,当调用间隔函数时,
将再次解除绑定(>
此==窗口
)。通过将其保存在自定义变量中,它将保留在函数的闭包中。

嵌套函数时,需要将此保存在另一个变量中,如下所示:

return $(this).each(function() {
    var self = this;
    setInterval(function() { $.slider(opt.direction , opt.slideSpeed, self); }
}

是函数的上下文,默认情况下它是全局对象
窗口
。jQuery在调用函数时将其设置为更有用的对象(例如
.each()
)中的元素。但是,当调用间隔函数时,
将再次解除绑定(>
此==窗口
)。通过将其保存在自定义变量中,它将保留在函数的闭包中。

只需将其转换为jQuery对象:

var $elm = $( elm );

只需将其转换为jQuery对象:

var $elm = $( elm );