How to call function in jquery plugin?
html, javascript, jquery
Solution
Do it like this:
(function($) {
//Assuming $.fn.top_islides is defined
$.fn.top_islides.ajax_init = function(){
init_islides();
setTimeout(picmove,300);
};
//.....
})(jQuery);
Or
(function($) {
$.fn.top_islides = function(){
var ajax_init = function(){
init_islides();
setTimeout(picmove,300);
};
return {
ajax_init: ajax_init
};
});
//.....
})(jQuery);
Problem
``` (function($) { $.fn.top_islides = function(){ var ajax_init = function(){ init_islides(); setTimeout(function(){picmove()},300); }; //..... }; })(jQuery); ``` call it in doucument ready in another file ``` $('#top_slides').top_islides(); $('#top_slides').top_islides().ajax_init(); ``` I thought it should work ,I got an error, what's the problem?