i am doing something like this
- //dom
- <div id='parent'>
- </div>
- //js
- var _doSomeThing=function()
- {
- //some codes
- }
- $(function(){
- //appending div and binding methods to span
- $('#parent).append('<span>1</span>');
- $('#parent).append('<span>2</span>');
- $('#parent span').bind('click',_doSomeThing);
- });
- function _clearDiv()
- {
- //clear div
- $('#parent).html('');
- }
- //sometime in future, call clear div
- _clearDiv();
now my question is, binding events to dom and later just removing the
elements from dom leads to memory leakage.
I read some where that doing this will lead to memory loss. As i just cleared the
div without unbinding the events.
my question is if i use $('#parent').empty()- to clear the div is this will
avoid memory leakage
if yes how to solve this problem.