Hyperscript unable to find element in DOM

159 Views Asked by At

I am trying to run the following code using hyperscript based on HTMX HX-Trigger tags as part of response.

<script type="text/hyperscript">
            on membershipsChanged
              log "memberships"
              remove .hidden from #alert-success
              wait 10s
              add .hidden to #alert-success
            end
 </script>

The HTML it is amending is

<div
            id="alert-success"
            class="hidden p-4 mb-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300"
            role="alert"
          >
            <span class="font-medium">Memberships updated successfully</span>
</div>

It is giving me error that #alert-success' is null. I have attempted to place <script> at different places such as above the element or beneath the element to see that it might pick the <div> with id="alert-success" but nothing is working though log provided using log "memberships" is visible in the consol.

0

There are 0 best solutions below