如何确定在一段时间内点击了哪个按钮

时间:2011-12-15 12:22:42

标签: php jquery html ajax

我在php中有一个while循环,用于获取查询结果(用户帖子)并显示查询中的数据。但是我也想在每个帖子的底部有两个按钮。我需要知道如何确定单击按钮的div,然后仅在该div中显示ajax函数的结果,谢谢。

1 个答案:

答案 0 :(得分:1)

您可以尝试

$('button').on("click",function(){
    var parent= $(this).parent();// will give you the Parent Object of the button, that has been clicked
});

所以在var parent中,HTML元素是你按钮的父元素(指定的div)。