> For the complete documentation index, see [llms.txt](https://jscula.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jscula.gitbook.io/docs/events/event-listener.md).

# Event Listener

### Alternatively you can use the `.on()` method

The `on` method receives any\* valid javascript event name\*, a callback function and optionaly, a config object

```javascript
$('.button').on('click',function(e){
//perform action here
});

$('.button').on('mouseleave',function(e){
//perform action here
});

$('.button').on('submit',function(e){
//perform action here
});

$('.button').on('keypress',function(e){
//perform action here
});

//etc...
```

### Still loves addEventListener and onclick, ...?

You can still use them as well.

```javascript
$('.button').addEventListener('click',(e)=>{ 
//perform action here 
});
```

```javascript
$('.button').onclick = function(e){ 
//perform action here 
};
```
