I know how to use the ‘addEventListener()’ and ‘removeEventListener()’ functions to an element.
[code]
elem.addEventListener(‘click’, externalFunction, false);
[code]
How can I test if the function has already been activated before? :confused:
For example, if I add an event listener function, what test is used to determine
if it is already in effect without calling the function again and create a duplicate
element event?
I am not asking how to disable an element, but how to toggle the eventlistener
function on/off based upon a logic test. The following does not seem to work:
[code]
if (!elem.addEventListener) {
elem.addEventListener(‘click’,externalFunction, false);
}
… later in program …
if (elem.removeEventListener) {
elem.removeEventListener(‘click’,externalFunction, false);
}
Do I need to somehow change the externalFunction to be ‘null’
when I don’t want the event to occur
and set it back to the function when needed? For example:
[code]
function externalFunction() { …. some action … }
… later in program …
externalFunction = null; // to de-activate event
… or …
externalFunction = ???; // to re-activate event if it had been de-activated
I don’t know if the above code is even feasible. ?