Jump to content

addEventListener method


diox76

Recommended Posts

Hi everyone,

 

According to the explanation about this method here, it accepts three parameters:

- new event created in runtime;

- anonymous (or not) function;

- a third parameter (boolean).

 

I would like to know if the first parameter can be a variable such as "newEvent" instead to write as literal ("click")

E.g.:

 

function myfunction(myId, newEvent)

{

document.getElementById(myId).addEventListener(newEvent, function(){

 

...

 

});

}

 

Is this possible? My idea is pass a value to my function as parameter to 'addEventListener' method.

 

Thanks in advance.

 

Best regards.

:)

Edited by diox76
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...