Add function to existing JQuery plugin

Posted by kralco626 on Stack Overflow See other posts from Stack Overflow or by kralco626
Published on 2011-01-11T13:30:03Z Indexed on 2011/01/11 13:53 UTC
Read the original article Hit count: 191

Filed under:
|
|
|

Is it possible to add a function to a plugin without modifying the actual plugin? Can I do something like this in my site's js file?

$.fn.Watermark.Refresh = function() {
        $.Watermark.HideAll();
        $.Watermark.ShowAll();
    }

or

(function($){
$.fn.Watermark.Refresh = function() {
        $.Watermark.HideAll();
        $.Watermark.ShowAll();
    };
})(jQuery);

neither worked, the first says $ is undefined, the second that jQuery is undefined...

ideas?

Solution: Either method works, just include the jquery file before the site js file.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery