B
bgold12
Hey, I just want to make sure that when I remove an element I don't
have to worry about the events listeners I added previously to the
element. For example:
// get the element by its id
elem = document.getElementById('elemId');
// attach the event listener
if (elem.addEventListener) { // std
elem.addEventListener(eventName, functionRef, false );
} else if (elem.attachEvent) { // ie
elem.attachEvent(eventName, functionRef );
} // end if
.... // whatever functionality makes use of the element and its event
(s)
// delete the element
elem.parentNode.removeChild(elem);
In this case, does the browser automatically destroy the events I
added previously, or do have to remove them myself?
Thanks.
have to worry about the events listeners I added previously to the
element. For example:
// get the element by its id
elem = document.getElementById('elemId');
// attach the event listener
if (elem.addEventListener) { // std
elem.addEventListener(eventName, functionRef, false );
} else if (elem.attachEvent) { // ie
elem.attachEvent(eventName, functionRef );
} // end if
.... // whatever functionality makes use of the element and its event
(s)
// delete the element
elem.parentNode.removeChild(elem);
In this case, does the browser automatically destroy the events I
added previously, or do have to remove them myself?
Thanks.