[英]Passing Parameters to Jquery Fadeout Function
I have a jquery fade-out call, and I'm trying to call a function on completion. 我有一个jQuery淡出调用,并且正在尝试在完成时调用一个函数。 This function will call another function inside of it that requires parameters from the object, which this block of code is inside.
此函数将在其中调用另一个函数,该函数需要对象的参数,此代码块位于其中。 So first I tried this:
所以首先我尝试了这个:
MyObject.prototype.myfunction = function myFunction() {
$(".my-class").fadeOut('slow', function() {
doSomething(this.one, this.two, this.three, this.four, this.five, this.six, this.seven);
} );
}
But I got an error so now I want to pass the function() after slow some parameters. 但是我遇到了一个错误,所以现在我想在慢一些参数之后传递function()。 How would I go about doing that.
我将如何去做。
Thanks, Michael 谢谢迈克尔
Your this
is referring to the wrong object 您
this
是指错误的对象
MyObject.prototype.myfunction = function myFunction() {
var self = this;
$(".my-class").fadeOut('slow', function() {
doSomething(self.one, self.two ..);
} );
}
The this
inside of the fadeout function is referring to the jquery object so setting self to MyObject outside of fadeout and you can use it inside of fadeout. 淡出功能的
this
内部是指jquery对象,因此可以在淡出之外将self设置为MyObject,并且可以在淡出内部使用它。 Your question dos not explain which object you are trying to pass things from but I assume this is what you want 您的问题没有说明您要从哪个对象传递信息,但是我想这就是您想要的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.