Calling Function Itself in jquery
I have func开发者_Go百科tion like below
$.fn.testFunction = function (options) {
$(window).resize(function () {
//call testfunction again
});
alert("Test");
}
If the window size changes, I want to call testFunction again. How can I do that ?
Thanks in advance,
Update: I just realized that you have options as well.
$.fn.testFunction = function _testFunction(options) {
$(window).resize(function () {
_testFunction(options);
});
alert("Test");
}
Your function gets stored in $.fn
object, so you try calling it from there again:
$.fn.testFunction = function (options) {
$(window).resize(function () {
$.fn.testFunction();
});
alert("Test");
}
精彩评论