# Events Marko’s event API supports: - [Browser events](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Events) on native tags - Custom events from [custom tags](./custom-tags.md) Note that **you can’t mix event targets and event types**: custom tags can only listen for custom events, and native tags can only listen for native events. ## Listening to events Both kinds of events are received with an `on-*` attribute and the [attribute arguments syntax](./syntax.md#arguments): ```marko console.info(`Checked? ${event.target.checked}`)) /> ``` The [first argument for the attribute can be a function](#function-handler), or [a string matching a method name](#method-handler) on the [component’s `class` declaration](./class-components.md). ### Function handler If you provide a function as the first argument of the `on-*` attribute, the function is called whenever the event fires, like standard event listeners. Below we use the [`static` prefix](./syntax.md#static-javascript) to define a function, then use it as a `click` handler: ```marko static function handleClick(event) { event.preventDefault(); console.log("Clicked!"); } ``` In the above example, any time the ` ``` …or anything that evaluates to a function: ```marko $ const handler = ( input.dontBreakMyApp ? () => console.error("Clicked!") : () => { throw Error("Clicked!") } ); ``` ### Method handler When a string is the first argument, Marko calls a matching method on the component's `class`. ```marko class { logChange(newTab) { console.log(`changed to: ${newTab}`); } } ``` When `` emits the `switch-tab` event, it will call its `logChange` method. Within the handler you can access the current component instance, read data, emit events, update state, etc. ### Binding additional arguments Arguments after the handler are prepended when the handler is called: ```marko static function removeFriend(friendId, event) { event.preventDefault(); window.myAPI.unfriend(friendId); } ``` Here we share the logic for `removeFriend()` with each `friend` in the `friends` array. When the `