From the course: Building Full-Stack Applications with HTMX

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Solution: Target destination within container element

Solution: Target destination within container element - HTMX Tutorial

From the course: Building Full-Stack Applications with HTMX

Solution: Target destination within container element

(bright upbeat music) - [Instructor] Now that we've taken our test to target a nested destination for our response, let us solve it together. So, we have this button that says Load Items and we have to load the response into this ul element inside the div with an id of container. So, that immediately screams hx-target. To solve that, we need to have an hx-target, and inside here, we need to construct our selector to make sure that it is targeting this unordered list and not just this container div. So, let's target that, say container, and inside container, target the unordered list. So here, we've built a selector that cascades down to the element that we want to target. Let us test our code. Let me pull the Console output up. Let's go and Test my code and all our tests are passing. All our tests are passing.

Contents