开发者

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");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜