I've got a bunch of buttons nested within div tags in my html
<div class="button-wrapper">
<button class="button-class">Click here</button>
</div>
<div class="button-wrapper">
<button class="button-class">Click here</button>
</div>
...
Clicking on the button posts some data using JQuery and returns some HTML through a .ajax success function. I'm trying to replace the content of the div for each button that is clicked, but for some reason my JQuery selector doesn't seem to be working.
I'm trying the following within my success function:
$(this).parent().html(data);
I know that the data is being posted successfully and that the success function is working. What's weird is that the following works:
$(".button-wrapper").html(data);
but obviously this adds the HTML to every div, not just the one for the button that is clicked.
Does anyone know where I might be going wrong here?
this. Could you post the script which does the insert job and let us see? We can't say much without taking a look at it.