Reputation: 20882
I have the following Jquery function.
I want to know how I can call it from outside the function. There are occasions where I need to run it. I can see how to trigger/call it from inside the function at the bottom but I'm unsure how to from outside of it.
$.fn.lazyload = function() {
var elem = this;
var lazyload = function(elem) {
var viewport_height = $(window).height() + 100;
var scrollTop = $(document).scrollTop();
}
lazyload(elem);
$(window).scroll(function(){lazyload(elem);});
$(window).resize(function(){lazyload(elem);});
};
I've tried the following but they don't work:
$.fn.lazyload(elem);
lazyload(elem);
lazyload();
thanks
Upvotes: 4
Views: 38