# Element: DOMActivate event



The **`DOMActivate`** event is fired at an element when it becomes active, such as when it is clicked on using the mouse or a keypress is used to navigate to it.

## Syntax

Use the event name in [addEventListener()](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget%2FaddEventListener):

```js-nolint
addEventListener("DOMActivate", (event) => { })
```

> **NOTE:**
> There is no `onDOMActivate` event handler property for this event.

## Event type

A [UIEvent](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent). Inherits from [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event).

## Examples

This example listens for `DOMActivate` on a [button](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button) element and displays its [detail](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent%2Fdetail).

### HTML

```html
<button>Click</button>
```

### JavaScript

```js
const button = document.querySelector("button");

button.addEventListener("DOMActivate", (event) => {
  button.textContent = `Click count: ${event.detail}`;
});
```

### Result

Note that `detail` of the `DOMActivate` event may have browser-specific behavior. It may either always be `0`, or have similar behavior as the [click](https://developer.mozilla.org/en-US/docs/Web/API/Element%2Fclick_event) event's `detail` (i.e., indicating the number of consecutive clicks).

## Specifications

## Browser compatibility

## See also

- [UIEvent](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent)
- [click](https://developer.mozilla.org/en-US/docs/Web/API/Element%2Fclick_event)
