--- title: "hx-on" description: "Runs inline JavaScript when an event fires" --- The `hx-on` attribute wires inline JavaScript to run when an event fires. It is an enhanced version of [`onevent` properties](https://developer.mozilla.org/en-US/docs/Web/Events/Event_handlers#using_onevent_properties) that keeps behavior in the markup ([Locality of Behaviour](/essays/locality-of-behaviour)). ## Syntax **Simple form** One event, one expression: ```html ``` For htmx events, use `::` as shorthand for `htmx:`: ```html ``` ### `changed` Only fires if the element's `value` changed since last time. ```html ``` Note: [`change`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event) is a DOM event. `changed` is an htmx modifier. Different things. ### `delay: