Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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/




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: