The documentation for hx-target says that transactions like hx-get and hx-post will only replace the first DOM node on the page that matches the criteria. This is true whether you're using the default action (which swaps out the current DOM node) or specifying your own CSS selector.
This is a pretty common question for htmx, and there's an example of several different ways to accomplish this on the website. This example lists three possible solutions:
- Use hx-target to swap a larger portion of the page.
- Use Out of Band Swaps
- Use custom events and hx-trigger to trigger additional swaps that follow after the initial one.
It's hard to say what's the "right" answer without looking at the rest of your use case. But my guess is that you could just expand the area you're targeting and call it a day.
<div id="swap-all-this">
<button
hx-get="/views/users/byId/someId"
hx-target="#swap-all-this">Details</button>
<div class="details">first</div>
<div class="details">second</div>
</div>