How do I replace an img src attribute with HTMX

134 views Asked by At

I'd like to replace the src attribute of an img element with the response of a form post.

What I'm doing right now is:

<form hx-post="/myurl" hx-trigger="load,change" hx-target="#output" hx-swap="src">
</form>

<img id="output" src=""/>

but what I get is

<img id="output" class="" src="">
out/528813151211e4736a4531358cda6af03fd3ce79a96d2f60108f3777e2715c92.webp
</src>

so, it appears a "class" attribute from nowhere and the value got from the post is not used as a value for the src attribute.

what am I doing wrong?

0

There are 0 answers