Skip to content
Advertisement

How can I add event listener to just button element

Here is my code.

JavaScript

then we can find simple button in DOM. Once I click button, script returns

JavaScript

or

JavaScript

.

How can I add event listener to just button element?

Advertisement

Answer

This is as one of the options… You can use the currentTarget.

In your case, it will be like this:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement