简单的插件:
(function ($) {
var MyTest = function (){
this.bigarr = new Array(20000);
this.init();
};
$.fn.extend({
mytest: function(options){
return this.each(function() {
new MyTest();
});
}
});
$.extend(MyTest.prototype, {
init: function(){
console.log(this);
}
});
})(jQuery);
然后我将插件附加到 DOM 元素:
$('#selector').mytest();
并删除元素:
$('#selector').remove();
插件会发生什么?大数组还存在于内存中吗?还是我必须手动删除它?
最佳答案
关于javascript - DOM 元素删除时是否删除 jquery 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6463705/