Hacker News new | ask | show | jobs
by gimme_treefiddy 1451 days ago
One of the things that I found lacking, was doing like general computing-esque business intelligence tasks in htmx. For example, how would you set src on image tag upon a click. Ended up having to use jquery.
2 comments

You should be able to do this with hyperscript.

    <img src="my_cat.jpg" alt="My cat" _="on click set @src to 'my_other_cat.jpg'">
I am not sure what the benefit of hyperscript would be here? Why not just use JavaScript + htmx?
Why not just use JavaScript + HTML?

  <img src="my_cat.jpg" alt="My cat" onclick="this.src = 'my_other_cat.jpg'">
Any more full example? Interested.
Vanilla JS v. jQuery v. hyperscript full examples here: https://hyperscript.org/comparison/
you'd use hyperscript for something client side like that:

on click set @src to "https://whatever.com/cat.gif"

the htmx approach would be to replace the image tag entirely