我有一个之间的效果,工作良好的点击事件,但我希望它与期刊工作。请帮帮我!提前谢谢。
// Tween effect
var bounce = function() {
this.set('tween', {duration: 1500, transition: 'bounce:out'});
this.tween('right', [900, 40]);
}
// This works fine
$('someID').addEvent('click', bounce);
// These don't work
bounce();
bounce.periodical(10000);发布于 2014-02-02 20:20:33
当您将bounce()附加到click事件时,您可以在该函数中使用this,但在函数之外,您需要定义"this“。您可以使用bind,也可以将this更改为元素。
试试这个:
var bounce = function() {
var element = $('someID'); // cache it here or outside the function
element.set('tween', {duration: 1500, transition: 'bounce:out'});
element.tween('right', [900, 40]);
}
bounce();
bounce.periodical(10000);https://stackoverflow.com/questions/21515429
复制相似问题