Reputation: 471
I have a while loop in php that fetches results of a query (a user post) and displays the data from the query. However i also want two buttons at the bottom of every post. I need to know how to determine which div the button was clicked in and then display the results of an ajax function in that div only, thanks.
Upvotes: 2
Views: 130
Reputation: 7536
You could simply try
$('button').on("click",function(){
var parent= $(this).parent();// will give you the Parent Object of the button, that has been clicked
});
So in var parent there's the HTML Element that is the parent of your button(the specified div).
Upvotes: 1