liveBook · Manning

Hx-target attribute

The hx-target attribute identifies the HTML element whose content or element HTMX updates with a request response.

How 2 Manning books explain it

Django in Action

hx-target is an HTMX attribute that identifies the HTML element whose content or element is affected by an HTMX response.

How it is used
Directs HTMX responses into a selected page region for dynamic updates without a full-page reload.
How deep it goes
Defines selector-based targeting and demonstrates it in a search template with partial-rendering Django views.
Examples
Uses a musician search input targeting a results div and an infinite-scroll results partial.
What you can do after
Apply it via HTMX to route a Django view’s partial HTML response into a selected element.

Read how Django in Action explains hx-target attribute →

Quarkus in Action

The hx-target attribute identifies the HTML element whose contents HTMX replaces with a response.

How it is used
Directs an HTMX request’s HTML response to the intended page element.
How deep it goes
Shows ID-based targeting in working markup and forms; does not elaborate other target expressions.
Examples
Uses a greeting button, an availability search form, and a car reservation form.
What you can do after
Apply it via HTMX to update a chosen page region from a backend response.

Read how Quarkus in Action explains hx-target attribute →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.