hx-target

The hx-target attribute allows you to target a different element for swapping than the one issuing the AJAX request. The value of this attribute can be:

Here is an example that targets a div:

<div>
    <div id="response-div"></div>
    <button hx-post="/register" hx-target="#response-div" hx-swap="beforeEnd">
        Register!
    </button>
</div>

The response from the /register url will be appended to the div with the id response-div.

Notes