[英]Remove function from a jquery object
How can I remove a function from a jquery object? 如何从jquery对象中删除函数? For example, I have
例如,我有
$('#element').func = function() {
// function body goes here
}
And later on I want to remove func
from $('#element')
. 然后,我想从
$('#element')
删除func
。 I've tried delete
but it doesn't work. 我试过
delete
但是不起作用。 Thanks. 谢谢。
How about this? 这个怎么样?
$('#element').fn.func = null;
or 要么
$('#element').prototype.func = null;
or 要么
delete $('#element').fn.func;
or 要么
delete $('#element').prototype.func;
For understanding what the prototype is, have a look here: How does JavaScript .prototype work? 要了解原型是什么,请在此处查看: JavaScript .prototype如何工作?
您可以通过分配null来完成。
$('#element').fn.func = null;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.