Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
79
rated 0 times [  82] [ 3]  / answers: 1 / hits: 17592  / 11 Years ago, fri, june 21, 2013, 12:00:00

How can I remove a function from a jquery object? For example, I have



$('#element').func = function() {
// function body goes here
}


And later on I want to remove func from $('#element'). I've tried delete but it doesn't work. Thanks.


More From » jquery

 Answers
9

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?


[#77499] Thursday, June 20, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
davism

Total Points: 339
Total Questions: 100
Total Answers: 100

Location: Sweden
Member since Fri, Apr 16, 2021
3 Years ago
;