javascript - Passing eventOption as argument to function -


module calls function other module registering , de-registering events on elements. i'm passing eventtype argument. getting error uncaught typeerror: elementobject.element.eventoption not function

elementobject = { element: document.getelementbyid("elemid"),... } eventregisterer(elementobject, addeventlistener) 

function event registration:

function eventregisterer(elementobject, eventoption){     elementobject.element.eventoption('change', changefunction) } function changefunction() {   .... } 

why storing addeventlistener argument not working?

found solution:

function eventregisterer(elementobject, eventoption){     elementobject.element[eventoption('change', changefunction)]; } 

using array-like notation instead of directly using property name did work.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -