diox76 Posted February 20, 2017 Share Posted February 20, 2017 (edited) 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 February 20, 2017 by diox76 Link to comment Share on other sites More sharing options...
Ingolme Posted February 20, 2017 Share Posted February 20, 2017 Yes, any string will work, literal or not. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now