this是对调用当前函数的成员的引用…
那么您可以将其包装在jquery函数中
$()以选择它,就像选择其他选择器一样。
因此
setInterval调用匿名函数,这样它就不会被可引用成员调用,因此它默认为该
window对象。
将
this上下文保存在变量中,然后像这样在内部使用它…
$(document).ready(function(){ $("#round").click(function(){ var clicked = this; //<----store the click context outside setInterval setInterval(function(){ $(clicked).animate( //<----------use it here {height: 250, width: 150, top:150, left: 425}, {duration: 300} ). animate( {height: 200, width: 200, top:200, left: 400}, {duration: 300} ); }, 0); });});


