# Events
Marko supports listening to [browser events](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Events) on native tags as well as custom events from [custom tags](./custom-tags.md) using the same API.
## Listening to events
All events emitted from native and custom tags can be received by using an `on-*` attribute in combination with the [attribute arguments](./syntax.md#arguments) syntax.
The first argument for the attribute must be a function or a string that maps to a predefined method on the component's [`class`](./class-components.md).
### Method handler
When a string is provided as the first argument Marko will look for a method on the component's `class` and call that.
```marko
class {
log(msg) {
...
}
logChange(newTab) {
this.log(`changed to: ${newTab}`);
}
}
...
```
When `my-tabs` emits the `switch-tab` event it will call the `logChange` method on this component.
The benefit here is that within the handler you will have access to the current component instance and be able to read data, emit events, update state, etc.
### Function handler
You can provide a function as the first argument of the `on-*` attribute. This function will be called whenever the event is fired. Below we use the [`static syntax`](./syntax.md#static-javascript) to define a function and use that.
```marko
static function handleClick(event) {
event.preventDefault();
console.log("Clicked!");
}
```
In the above example, any time the `