【发布时间】:2012-07-28 15:07:30
【问题描述】:
我在访问帖子中的函数内部的 $(this) 时遇到了很多麻烦 我要做的就是根据响应删除对象类。
$.post("url.php?"+theData, {}, function(response){ etc.....
使用静态 #ID 可以正常工作,但我更愿意操纵 $this
【问题讨论】:
-
如果您正在执行类似
$('element').click(function(){ $.post(){的操作,您需要在帖子之前存储对 $(this) 的引用,以便您可以在函数中引用它,例如$('element').cilck(function(){ var me = $(this); $.post("url.php?"+theData, {}, function(resposne({ //me is now $(this); }); }); -
这可能只是范围问题,但发布更多代码,也许可以使用变量代替,但您的代码示例现在什么都没有显示?
标签: javascript jquery html ajax this