2

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.

2 Answers 2

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?

Sign up to request clarification or add additional context in comments.

Comments

1

you can do by assigning null.

$('#element').fn.func = null;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.