---
title: Onclick Event Attribute
---
## Onclick Event Attribute
When the element is clicked fires a event.
It works just like the *onclick method* or `addEventListener('click')` to the element.
```html
``` element when clicked ```html
Change my color
``` Using raw JavaScript onclick attribute: ```html ``` #### More Information: - [MDN](https://developer.mozilla.org/pt-BR/docs/Web/API/GlobalEventHandlers/onclick)