我在php中有一个while循环,它获取查询(用户发布)的结果并显示查询中的数据。然而,我也希望在每个帖子的底部有两个按钮。我需要知道如何确定按钮是在哪个div中单击的,然后只在该div中显示ajax函数的结果,谢谢。
发布于 2011-12-15 20:28:15
你可以简单地试着
$('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)的父元素。
https://stackoverflow.com/questions/8520068
复制相似问题