![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
try posting to comp.lang.javascript On Fri, 21 Nov 2008 05:51:26 -0800 (PST), bgold12 <bgol... (AT) gmail (DOT) com wrote: 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. |
#4
| |||
| |||
|
|
On Nov 21, 8:12*am, richard <mem... (AT) newsguy (DOT) com> wrote: try posting to comp.lang.javascript On Fri, 21 Nov 2008 05:51:26 -0800 (PST), bgold12 <bgol... (AT) gmail (DOT) com wrote: 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. That's an interesting question. You could add the Element back to the DOM after removing it and then see if it's still there when you click on it. |
#5
| |||
| |||
|
|
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? |
#6
| |||
| |||
|
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |